Use Screen-Saver Passwords

When you write a screen saver in C and the Windows SDK, a static library (SCRNSAVE.lib) allows you to create custom dialogs to change and request the password. But in VB you can’t use this library. If you don’t want to create forms to replace the custom dialogs, use these two undocumented functions:

 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?as a child of hWnd. The two reserved parameters should be zero. VerifyScreen-SavePwd, in password.cpl, pops up a dialog box as a child of hWnd, prompting for the screen saver’s password. If the user gets it wrong, it prints a message saying so and prompts for the password again. If the user presses OK, VerifyScreenSavePwd returns True; if the user presses Cancel, it returns False. These calls?and the DLLs?exist in Windows 95/98 but not in NT because NT handles password management at the system level. Here’s how you can use the PwdChangePassword call:

 Private Sub cmdChange_Click()	PwdChangePassword "SCRSAVE", Me.hWnd, 0, 0End Sub

You must use the string “SCRSAVE” as the first parameter to PwdChangePassword, because it has special meaning and the function fails if another string is passed. Call VerifyScreenSavePwd on detection of mouse or keyboard activity, passing the hWnd the dialog should be owned by. Here’s a simple example of how to test this function:

 Private Sub cmdTest_Click()	Dim bRes As Boolean	bRes = VerifyScreenSavePwd(Me.hWnd)	MsgBox bResEnd Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS