If you are not using the C library then you have to implement your own password security, encrypting the password and placing it in the CONTROL.INI
e.g.
[Screen Saver.Ships] PWProtected=0 Password=F-/EkoF
// This only ever gets called under '95, when started with the /a option.
HINSTANCE hmpr=::LoadLibrary("MPR.DLL");
if (hmpr==NULL)
{
TRACE("MPR.DLL not found: cannot change password.");
return;
}
typedef VOID (WINAPI *PWDCHANGEPASSWORD)
(LPCSTR lpcRegkeyname,HWND hwnd,UINT uiReserved1,UINT uiReserved2);
PWDCHANGEPASSWORD PwdChangePassword=(PWDCHANGEPASSWORD)::GetProcAddress(hmpr,"PwdChangePasswordA");
if (PwdChangePassword==NULL)
{
FreeLibrary(hmpr);
TRACE("PwdChangeProc not found: cannot change password");
return;
}
PwdChangePassword("SCRSAVE",m_hWnd,0,0);
FreeLibrary(hmpr);
To verify the password, the password control pannel applet is used. Strangely enough you cannot manually change your password from the control pannel. This should only be done if you are not running on NT hence the version check.
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize=sizeof(osv);
GetVersionEx(&osv);
if (osv.dwPlatformId==VER_PLATFORM_WIN32_NT)
return;
HINSTANCE hpwdcpl=::LoadLibrary("PASSWORD.CPL");
if (hpwdcpl==NULL)
{
TRACE("Unable to load PASSWORD.CPL. Aborting\n");
return;
}
typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
TRACE("DLL loaded\n");
VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
VerifyScreenSavePwd=
(VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl,"VerifyScreenSavePwd");
if (VerifyScreenSavePwd==NULL)
{
TRACE("Unable to get VerifyPwProc address. Aborting\n");
FreeLibrary(hpwdcpl);
return;
}
TRACE("About to call VerifyPwProc\n");
BOOL bres=VerifyScreenSavePwd(m_hWnd);
FreeLibrary(hpwdcpl);
return;
You do not need to independantly check that the screensaver password is being used, the VerifyScreenSavePWD does this for you.