2006-11-08 11:47:44 +00:00
|
|
|
//
|
|
|
|
// password.c
|
|
|
|
//
|
|
|
|
// Password support for Win9x
|
|
|
|
//
|
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
|
|
|
|
typedef VOID (WINAPI *PWDCHANGEPASSWORD)(LPCTSTR lpcRegkeyname, HWND hwnd,UINT uiReserved1,UINT uiReserved2);
|
|
|
|
|
|
|
|
BOOL VerifyPassword(HWND hwnd)
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2006-11-08 11:47:44 +00:00
|
|
|
// Under NT, we return TRUE immediately. This lets the saver quit,
|
|
|
|
// and the system manages passwords. Under '95, we call VerifyScreenSavePwd.
|
|
|
|
// This checks the appropriate registry key and, if necessary,
|
|
|
|
// pops up a verify dialog
|
|
|
|
|
|
|
|
HINSTANCE hpwdcpl;
|
|
|
|
VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
|
|
|
|
BOOL fResult;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
if(GetVersion() < 0x80000000)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
hpwdcpl = LoadLibrary(_T("PASSWORD.CPL"));
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if(hpwdcpl == NULL)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
VerifyScreenSavePwd = (VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl, "VerifyScreenSavePwd");
|
|
|
|
|
|
|
|
if(VerifyScreenSavePwd == NULL)
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2006-11-08 11:47:44 +00:00
|
|
|
FreeLibrary(hpwdcpl);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
fResult = VerifyScreenSavePwd(hwnd);
|
2006-11-08 11:47:44 +00:00
|
|
|
FreeLibrary(hpwdcpl);
|
|
|
|
|
|
|
|
return fResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ChangePassword(HWND hwnd)
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2006-11-08 11:47:44 +00:00
|
|
|
// This only ever gets called under '95, when started with the /a option.
|
|
|
|
HINSTANCE hmpr = LoadLibrary(_T("MPR.DLL"));
|
|
|
|
PWDCHANGEPASSWORD PwdChangePassword;
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if(hmpr == NULL)
|
2006-11-08 11:47:44 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
PwdChangePassword = (PWDCHANGEPASSWORD)GetProcAddress(hmpr, "PwdChangePasswordA");
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
if(PwdChangePassword == NULL)
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2006-11-08 11:47:44 +00:00
|
|
|
FreeLibrary(hmpr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
PwdChangePassword(_T("SCRSAVE"), hwnd, 0, 0);
|
2006-11-08 11:47:44 +00:00
|
|
|
FreeLibrary(hmpr);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|