S
songguolong
Unregistered / Unconfirmed
GUEST, unregistred user!
1、如何在自编的屏保程序中启用控制面版中的口令设置来设置共享口令?
2、退出运行着的屏保程序时采用如下方法进行口令较对, 为什么不能取消?
procedure TfrmScreenSaver.CloseIfOk;
var hLib:THandle;
P:function(Parent:THandle):Boolean; stdcall;
SysDir:String;
NewLength:Integer;
Registry:TRegistry;
OSVer:TOSVersionInfo;
begin
//首先检测windows版本,因为NT和win98/95处理方法不同
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;
2、退出运行着的屏保程序时采用如下方法进行口令较对, 为什么不能取消?
procedure TfrmScreenSaver.CloseIfOk;
var hLib:THandle;
P:function(Parent:THandle):Boolean; stdcall;
SysDir:String;
NewLength:Integer;
Registry:TRegistry;
OSVer:TOSVersionInfo;
begin
//首先检测windows版本,因为NT和win98/95处理方法不同
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;