I'm a complete noob in c++, wasn't going to learn it any time soon, but somehow i've been delegated a small c++ task. I need to write a programm, that'll show a list of users of the windows After searching for a while on forums i found the script as follows:
#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);
}
When compiling, i get the following errors:
main.cpp:25: undefined reference to `NetUserEnum'
main.cpp:62: undefined reference to `NetApiBufferFree'
What am i doing wrong? Aren't the methods included in one of the include directive?