#include <windows.h> /*Proudly to be compiled with MingW!*/
#include <scrnsave.h>
#define TIMER 101
int randomx(int max, int seeder); /*Crappy RNG written by me*/
HINSTANCE hInstance;
LONG WINAPI ScreenSaverProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static HDC hDC;
static int Width, Height;
static RECT rect;
PAINTSTRUCT ps;
switch ( message ) {
case WM_CREATE:
// get window dimensions
GetClientRect( hWnd, &rect );
Width = rect.right;
Height = rect.bottom;
SetTimer( hWnd, TIMER, 200 /*Delay in milliseconds*/, NULL );
hInstance = hMainInstance;
/*Initialization stuff goes here*/
return 0;
case WM_DESTROY:
KillTimer( hWnd, TIMER );
/* Clean up after yourself... */
return 0;
case WM_TIMER:
/*Evertime the timer ticks, the stuff in here happens, you can add more timers and have*/
/*pretty complex timing thingys with certain things happening when a particular timer ticks*/
/*However, I have no intention of going into that now.*/
InvalidateRect(hWnd, NULL, FALSE);
/*Currently, the only thing it'll do on a timer message is tell*/
/*the Window that it needs to repaint the Window.*/
return 0;
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
/*PAINT THE WINDOW TIME! Here's were you get to paint the Window of the ScreenSaver*/
EndPaint(hWnd, &ps);
return 0;
}
/*Any other messages?...It's the screensaver-library's problem...*/
return DefScreenSaverProc(hWnd, message, wParam, lParam );
}
BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
/*After you add a configuration dialog, you can fill in all the stuff that goes here,*/
/*it's just a dialog proc really*/
return FALSE;
}
BOOL WINAPI RegisterDialogClasses(HANDLE dlg)
{
return TRUE;
}
BOOL VerifyPassword(HWND hwnd) /*Thanks to B. G. Edmond for writing these to password functions.*/
{
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize=sizeof(osv);
GetVersionEx(&osv);
if (osv.dwPlatformId==VER_PLATFORM_WIN32_NT)
{return TRUE;}
HINSTANCE hpwdcpl=LoadLibrary("PASSWORD.CPL");
if (hpwdcpl==NULL) {return TRUE;}
typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd);
VERIFYSCREENSAVEPWD VerifyScreenSavePwd;
VerifyScreenSavePwd=(VERIFYSCREENSAVEPWD)GetProcAddress(hpwdcpl,"VerifyScreenSavePwd");
if (VerifyScreenSavePwd==NULL) {FreeLibrary(hpwdcpl);return TRUE;}
BOOL bres=VerifyScreenSavePwd(hwnd); FreeLibrary(hpwdcpl);
return bres;
}
void ChangePassword(HWND hwnd)
{ // This only ever gets called under '95, when started with the /a option.
HINSTANCE hmpr=LoadLibrary("MPR.DLL");
if (hmpr==NULL) {return;}
typedef VOID (WINAPI *PWDCHANGEPASSWORD) (LPCSTR lpcRegkeyname,HWND hwnd,UINT uiReserved1,UINT uiReserved2);
PWDCHANGEPASSWORD PwdChangePassword=(PWDCHANGEPASSWORD)GetProcAddress(hmpr,"PwdChangePasswordA");
if (PwdChangePassword==NULL) {FreeLibrary(hmpr); return;}
PwdChangePassword("SCRSAVE",hwnd,0,0); FreeLibrary(hmpr);
}
int randomx(int max, int seeder) /*A random number generator...very basic*/
{
SYSTEMTIME gen;
static seed = 1;
float temp;
int number;
if(max == -1)
{seed = seeder; return 0;}
GetLocalTime(&gen);
/*
temp = (gen.wMilliseconds * 1.34765350008) + (gen.wSecond * 1.00000865) + (seed * 0.985) + (seed * 2.341188106 * max);
temp = temp * 2;
-Most Random so far*/
temp = (gen.wMilliseconds * 1.34765350008) + (gen.wSecond * 1.00000865) + (seed * 0.985) + (seed * 2.341188106 * max * (seed*0.15));
temp = temp * 2.1;
if(max == 0)
{return (int)temp;}
seed++;
if(seed > 1900)
{seed = 1;}
number = (long)temp % max;
return number;
}
|
#include |