15,478
社区成员
发帖
与我相关
我的任务
分享
#include <iostream.h>
#include <windows.h>
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"Advapi32.lib")
void main()
{
HANDLE hUser;
char szUserName[MAX_PATH] = "administrator";
char szPassWord[MAX_PATH] = "visualstudio";
if(LogonUser(szUserName,".",szPassWord,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hUser))
{
cout<<"Windows用户密码正确!"<<endl;
}
else
{
cout<<"Windows用户或密码错误!"<<endl;
}
}
#include <iostream.h>
#include <windows.h>
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"Advapi32.lib")
void main()
{
HANDLE hUser;
char szUserName[MAX_PATH] = "administrator";
char szPassWord[MAX_PATH] = "visualstudio";
bool bret = LogonUser(szUserName,".",szPassWord,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hUser);
if (!bret && (strlen(strPassWord == 0) && (GetLastError()==1327) ))
bret = true;
if(bret)
{
cout<<"Windows用户密码正确!"<<endl;
}
else
{
cout<<"Windows用户或密码错误!"<<endl;
}
}