网站首页  词典首页

请输入您要查询的函数:

 

术语 netapibufferallocate
释义 NetApiBufferAllocate
语法:
C++
NET_API_STATUS NetApiBufferAllocate(
__in DWORD ByteCount,
__out LPVOID *Buffer
);
NetApiBufferAllocate功能
该NetApiBufferAllocate函数分配的堆内存。使用此功能只有在与NetApiBufferFree功能兼容性是必需的。否则,使用内存管理功能。
参数
ByteCount [in]
字节数分配。
缓冲区[out]
接收一个指针分配的缓冲区。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值是一个系统错误代码。对于一个错误代码的列表,请参见系统错误代码。
备注
没有特殊组成员必须成功地执行ApiBuffer功能。
有关更多信息,请参阅网络管理功能,缓冲器和网络管理功能缓冲区长度。
实例
下面的代码示例演示如何使用网络管理ApiBuffer功能。
该示例首先调用NetApiBufferAllocate函数分配内存,然后NetApiBufferSize函数来检索所分配的内存大小。在此之后,该示例调用NetApiBufferReallocate改变内存分配的大小。 Finally, the sample calls NetApiBufferFree to free the memory.在每一种情况下,样本打印一条消息,表明成功或失败。
#define UNICODE
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
void PrintError(LPSTR lpszApi, DWORD res);
int main()
{
PUSER_INFO_10 p;
DWORD res, dwSize;
// Call the NetApiBufferAllocate function
// to allocate the memory. If successful,
// print a message.
//
res = NetApiBufferAllocate(1024, (LPVOID *) &p);
if(res == NERR_Success)
{
printf("NetApiBufferAllocate: Allocated 1024 bytes.\\n");
// Call the NetApiBufferSize function
// to retrieve the size of the allocated buffer.
// If successful, print the size.
//
res = NetApiBufferSize(p, &dwSize);
if(res == NERR_Success)
{
printf("NetApiBufferSize: Buffer has %u bytes.\\n", dwSize);
// Call the NetApiBufferReallocate function
// to change the size of the allocated memory.
// If successful, print the new size of the buffer.
//
res = NetApiBufferReallocate(p, dwSize * 2, (LPVOID *) &p);
if(res == NERR_Success)
printf("NetApiBufferReallocate: Re-Allocated %u bytes.\\n", dwSize * 2);
else
PrintError("NetApiBufferReallocate", res);
// Call the NetApiBufferFree function
// to free the allocated memory.
// If successful, print a message.
//
res = NetApiBufferFree(p);
if(res == NERR_Success)
printf("Freed Buffer\\n");
else
PrintError("NetApiBufferFree", res);
}
else
PrintError("NetApiBufferSize", res);
}
else
PrintError("NetApiBufferAllocate", res);
return 0;
}
void PrintError(LPSTR lpszApi, DWORD res)
{
printf("%s: Error %u\\n", lpszApi, res);
return;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmapibuf.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
阿比缓冲功能
NetApiBufferFree
NetApiBufferReallocate
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月13日
==英文原文==NetApiBufferAllocate Function
The NetApiBufferAllocate function allocates memory from the heap. Use this function only when compatibility with the NetApiBufferFree function is required. Otherwise, use the memory management functions .
Syntax
C++
NET_API_STATUS NetApiBufferAllocate(
__in DWORD ByteCount,
__out LPVOID *Buffer
);
Parameters
ByteCount [in]
Number of bytes to be allocated.
Buffer [out]
Receives a pointer to the allocated buffer.
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes .
Remarks
No special group membership is required to successfully execute the ApiBuffer functions.
For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths .
Examples
The following code sample demonstrates how to use the network management ApiBuffer functions .
The sample first calls the NetApiBufferAllocate function to allocate memory and then the NetApiBufferSize function to retrieve the size of the allocated memory. Following this, the sample calls NetApiBufferReallocate to change the size of the memory allocation. Finally, the sample calls NetApiBufferFree to free the memory. In each case, the sample prints a message indicating success or failure.
#define UNICODE
#include
#include
#include
#pragma comment(lib, "netapi32.lib")
void PrintError(LPSTR lpszApi, DWORD res);
int main()
{
PUSER_INFO_10 p;
DWORD res, dwSize;
// Call the NetApiBufferAllocate function
// to allocate the memory. If successful,
// print a message.
//
res = NetApiBufferAllocate(1024, (LPVOID *) &p);
if(res == NERR_Success)
{
printf("NetApiBufferAllocate: Allocated 1024 bytes.\\n");
// Call the NetApiBufferSize function
// to retrieve the size of the allocated buffer.
// If successful, print the size.
//
res = NetApiBufferSize(p, &dwSize);
if(res == NERR_Success)
{
printf("NetApiBufferSize: Buffer has %u bytes.\\n", dwSize);
// Call the NetApiBufferReallocate function
// to change the size of the allocated memory.
// If successful, print the new size of the buffer.
//
res = NetApiBufferReallocate(p, dwSize * 2, (LPVOID *) &p);
if(res == NERR_Success)
printf("NetApiBufferReallocate: Re-Allocated %u bytes.\\n", dwSize * 2);
else
PrintError("NetApiBufferReallocate", res);
// Call the NetApiBufferFree function
// to free the allocated memory.
// If successful, print a message.
//
res = NetApiBufferFree(p);
if(res == NERR_Success)
printf("Freed Buffer\\n");
else
PrintError("NetApiBufferFree", res);
}
else
PrintError("NetApiBufferSize", res);
}
else
PrintError("NetApiBufferAllocate", res);
return 0;
}
void PrintError(LPSTR lpszApi, DWORD res)
{
printf("%s: Error %u\\n", lpszApi, res);
return;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmapibuf.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Api Buffer Functions
NetApiBufferFree
NetApiBufferReallocate
Send comments about this topic to Microsoft
Build date: 8/13/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa370302(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:27:45