我在msdn上查NetUserGetInfo看到的例子
#ifndef UNICODE
#define UNICODE
#endif#include <stdio.h>
#include <windows.h>
#include <lm.h>int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 10;
LPUSER_INFO_10 pBuf = NULL;
NET_API_STATUS nStatus; if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
//
// Call the NetUserGetInfo function; specify level 10.
//
nStatus = NetUserGetInfo(argv[1],
argv[2],
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds, print the user information.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
wprintf(L"\n\tAccount: %s\n", pBuf->usri10_name);
wprintf(L"\tComment: %s\n", pBuf->usri10_comment);
wprintf(L"\tUser comment: %s\n", pBuf->usri10_usr_comment);
wprintf(L"\tFull name: %s\n", pBuf->usri10_full_name);
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf); return 0;
}Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Lmaccess.h; include Lm.h.
Library Link to Netapi32.lib.
DLL Requires Netapi32.dll.
我用vs2005建立一个工程,将代码复制到源文件,将项目属性-》连接器-》常规的附加库目录改为..\release,将项目属性-》连接器-》输入的附加依赖项改为Netapi32.dll,如何将机子上的Netapi32.dll复制到..\release文件夹下,release模式下生成,出现错误 1 fatal error LNK1107: 文件无效或损坏: 无法在 0x278 处读取 d:\My Documents\Visual Studio 2005\Projects\test\release\Netapi32.dll 1
#ifndef UNICODE
#define UNICODE
#endif#include <stdio.h>
#include <windows.h>
#include <lm.h>int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 10;
LPUSER_INFO_10 pBuf = NULL;
NET_API_STATUS nStatus; if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
//
// Call the NetUserGetInfo function; specify level 10.
//
nStatus = NetUserGetInfo(argv[1],
argv[2],
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds, print the user information.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
wprintf(L"\n\tAccount: %s\n", pBuf->usri10_name);
wprintf(L"\tComment: %s\n", pBuf->usri10_comment);
wprintf(L"\tUser comment: %s\n", pBuf->usri10_usr_comment);
wprintf(L"\tFull name: %s\n", pBuf->usri10_full_name);
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf); return 0;
}Requirements
Client Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
Server Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header Declared in Lmaccess.h; include Lm.h.
Library Link to Netapi32.lib.
DLL Requires Netapi32.dll.
我用vs2005建立一个工程,将代码复制到源文件,将项目属性-》连接器-》常规的附加库目录改为..\release,将项目属性-》连接器-》输入的附加依赖项改为Netapi32.dll,如何将机子上的Netapi32.dll复制到..\release文件夹下,release模式下生成,出现错误 1 fatal error LNK1107: 文件无效或损坏: 无法在 0x278 处读取 d:\My Documents\Visual Studio 2005\Projects\test\release\Netapi32.dll 1
解决方案 »
- tab自绘//不知道添加什么函数每个标签变成一个窗口?
- 【有图】C++实现winsock,S10014错误,C10016错误。。同一个位置,求大神。
- GDI+ 绘制图片的问题?
- 自己写SOCKET程序发送电子邮件,使用UTF-8、gb2312编码邮件内容在outlook或者 Foxmail中都正常显示。
- UNICODE,ANSI,MBCS是怎样工作的?
- 如何把CFile对象定义成成员变量
- 急!全局结构体变量问题
- 请问谁知道我用CString[] 表示字符数组,但老是说我unknown character '0xa1'
- 关于一个WINCE上做一个ZIP/UNZIP实现的提问
- win7 VS2010 MSComm
- GetDlgItem返回是个句柄,怎么可以->调用函数呢?GetDlgItem(IDOK)->EnableWindow(FALSE);
- 8583报文是用什么方法发送的
#pragma comment(lib , "Netapi32.lib")
试试。
解决方法:
项目-->项目属性-->配置属性-->清单工具-->使用FAT32解决方法为 是
就OK了。我也找了很久才成功的。祝你好运~~