嘿嘿,不好意思,晚上回家后就忙着写自己的程序,把这事给忘了,今天起床跑到
大富翁逛逛,才想起来. 函数见下:
procedure TfrmScreenSaver.CloseIfOk;
var hLib:THandle;
P:function(Parent:THandle):Boolean;
stdcall;
SysDir:String;
NewLength:Integer;
Registry:TRegistry;
OSVer:TOSVersionInfo;
begin
OSVer.dwOSVersionInfoSize:=SizeOf(OSVer);
GetVersionEx(OSVer);
if OSVer.dwPlatformID=VER_PLATFORM_WIN32_WINDOWS then
//如果是win98/95
begin
Registry:=TRegistry.Create;
Registry.RootKey:=HKEY_CURRENT_USER;
if Registry.OpenKey('Control Panel/desktop',false) then
begin
if Registry.ReadInteger('ScreenSaveUsePassword')<>0 then
begin
ShowCursor(True);
//激活鼠标
//从系统目录动态调入库PASSWORD.CPL
SetLength(SysDir,MAX_PATH);
NewLength:=GetSystemDirectory(PChar(SysDir),MAX_PATH);
SetLength(SysDir,NewLength);
if (length(SysDir)>0) and (SysDir[length(SysDir)]<>'/') then
SysDir:=SysDir+'/';
hLib:=LoadLibrary(PChar(SysDir+'PASSWORD.CPL'));
if hLib=0 then
Close //如果DLL没找到,直接关闭程序
else
begin
//显示口令校验对话框
P:=GetProcAddress(hLib,'VerifyScreenSavePwd');
if P(Handle) then
//校验成功则关闭
Close;
FreeLibrary(hLib);
//释放PASSWORD.CPL
end;
ShowCursor(False);
//隐藏鼠标
end
else
Close;
end
else
Close;
end
else
if OSVer.dwPlatformID=VER_PLATFORM_WIN32_NT then
//如果是Windows NT
begin
//口令被NT控制, 直接关闭程序即可
Close;
end
else
//既不是NT也不是Win9x,直接关闭程序
Close;
end;