Here is my code which works on Windows 7 (Visual Studio 2013 Express installed )
not on my Windows 10 (Visual Studio 2015 Community installed)
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "netapi32.lib") //heard this is dynamic linking ?
#include <windows.h>
#include <lm.h>
int main()
{
USER_INFO_1 ui;
DWORD dwLevel = 1;
DWORD dwError = 0;
//NET_API_STATUS nStatus;
ui.usri1_name = L"OMG";
ui.usri1_password = L"Bitch@2015";
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_PASSWD_CANT_CHANGE;
ui.usri1_script_path = NULL;
NetUserAdd(NULL,dwLevel,(LPBYTE)&ui,&dwError);
}
//Just call the NetUserAdd() function ! nothing else
//It requires netapi32.dll to run ! and maybe netapi32.lib too
//I know how to compile .lib against source.cpp to make a standalone program
Here are my questions :
1. Why can't the code work on another Windows 7 without Visual Studio installed ?(Even there is a netapi32.dll file in the system folder !)
2. Why can't it run on Windows 10 ?
3. Where to find the netapi32.lib file ? so I can use it to make a standalone program .(static linking )(it requires netapi32.dll to run , so I think it is still a dynamic linked program )
Help please , I've been researching on this topic for so long .
I read other people's post , my problem solved ,anyone encounters this problem ,can refer to
this link :
http://www.cplusplus.com/forum/windows/182467/
Good luck everyone !