When you write a screen saver in C and SDK you can use a static library (SCRNSAVE.LIB) that allows you to create custom dialogs to change and request the password. In VB you can’t access this library, but if you don’t want to create your forms to replace the custom dialogs, you can use a couple of undocumented functions. Unfortunately, these are only available only Windows 95 and 98, but not under Windows NT:
Declare Sub PwdChangePassword Lib "mpr.dll" Alias "PwdChangePasswordA" (ByVal _ lpcRegkeyname As String, ByVal hwnd As Long, ByVal uiReserved1 As Long, _ ByVal uiReserved2 As Long)Declare Function VerifyScreenSavePwd Lib "password.cpl" (ByVal hwnd As Long) As _ Boolean
PwdChangePassword is in MPR.DLL, the Multiple Provider Router. It does all the password management associated with Regkeyname, including popping up a dialog box (as a child of the window referred to by the hWnd handle). The two reserved arguments should be zero.
VerifyScreenSavePwd is in PASSWORD.CPL. It pops up a dialog box (as child of hWnd) that prompts for the screen saver’s password. If the user enters a wrong password, it prints a message saying so and prompts for it again. If the user presses OK then it returns True; if the user presses Cancel, then it returns False. This is an example of their use:
Private Sub cmdChange_Click() PwdChangePassword "SCRSAVE", Me.hwnd, 0, 0End Sub Private Sub cmdTest_Click() Dim bRes As Boolean bRes = VerifyScreenSavePwd(Me.hwnd) MsgBox bResEnd Sub