Re: [AD] scrsave.c password patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sunday 03 April 2005 12:52, guilt wrote:
> i discovered this code in DXutil and am putting it up as a patch to
> scrsave.c to prompt for a password .. please let me know if you aren't
> having troubles running this code .. if you don't please make a diff
> out of it and submit it to AD .. :)  it compiles well. should execute
> well.

I generated the attached patch from the file you posted. Hope I didn't miss 
anything here.
If the patch is indeed clean and what you intended I'll apply it.

Evert
Index: tests/win/scrsave.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tests/win/scrsave.c,v
retrieving revision 1.7
diff -u -r1.7 scrsave.c
--- tests/win/scrsave.c	21 Sep 2003 14:01:56 -0000	1.7
+++ tests/win/scrsave.c	7 Apr 2005 15:22:14 -0000
@@ -267,9 +267,25 @@
 /* the password dialog function */
 int do_password(HANDLE hInstance, HANDLE hPrevInstance, HWND hParentWnd)
 {
-   MessageBox(hParentWnd, "Sorry, this screensaver doesn't implement the password stuff", "Allegro Screensaver", MB_OK);
+    /* Load the password change DLL */
+    HINSTANCE mpr = LoadLibrary(TEXT("MPR.DLL"));
+    if (mpr)
+    {
+        /* Grab the password change function from it */
+        typedef DWORD (PASCAL *PWCHGPROC)(LPCSTR, HWND, DWORD, LPVOID);
+        PWCHGPROC pwd = (PWCHGPROC)GetProcAddress(mpr, "PwdChangePasswordA");
+
+        /* Do the password change */
+        if ( pwd != NULL )
+            pwd("SCRSAVE", hParentWnd, 0, NULL);
+
+        /* Free the library */
+        FreeLibrary(mpr);
+		mpr=NULL;
+		return 0;
+    }   
 
-   return 0;
+   return -1;
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/