我是c ++中的一个完整的菜鸟,不会很快再学习它,但是不知何故我被委派了一个小的c ++任务。我需要编写一个程序,该程序将显示Windows用户列表 在论坛上搜索了一段时间后,我发现脚本如下:
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib")
#include <stdio.h>
#include <windows.h>
#include <lm.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL, "Rus");
DWORD dwlevel = 0;
DWORD dwfilter = 0;
USER_INFO_0 * theEntries = new USER_INFO_0[20];
DWORD dwprefmaxlen = 512;
DWORD dwentriesread;
DWORD dwtotalentries;
NET_API_STATUS result;
result = NetUserEnum(NULL, dwlevel, dwfilter, (LPBYTE*)&theEntries, dwprefmaxlen, &dwentriesread, &dwtotalentries, NULL);
for (int i = 0; i < dwentriesread; i++)
{
printf("%i: ", i+1);
wprintf(L"%s \n", theEntries[i].usri0_name);
}
NetApiBufferFree(theEntries);
}
编译时出现以下错误:
main.cpp:25: undefined reference to `NetUserEnum'
main.cpp:62: undefined reference to `NetApiBufferFree'
我在做什么错?方法不是包含在include指令之一中吗?