This works:

function KillScreenSaverFunc(hwnd: HWND; lParam: lParam):Boolean; stdcall;
begin
  Result:=FALSE;
  if(IsWindowVisible(hwnd)) then
  begin
    PostMessage(hwnd, WM_CLOSE, 0, 0);
    Result:=TRUE;
  end;
end;

procedure TForm1.ByeByeScreenSaver(Sender: TObject);
var hdesk: longword;
begin
  hdesk := OpenDesktop('Screen-saver',0,False,
DESKTOP_READOBJECTS or DESKTOP_WRITEOBJECTS);
  if (hdesk<>0) then
  begin
    EnumDesktopWindows(hdesk, @KillScreenSaverFunc, 0);
    CloseDesktop(hdesk);
  end;
end;


> [cut]
> 
> 3. The following snippet of C code from MS support
> http://support.microsoft.com/support/kb/articles/q140/7/23.asp
> offers a method which when translated to Delphi syntax  produces a Handle
> but does not close the screen saver window. Anyone able to improve on this?
> This is obviously difficult to debug!, (in this case the screensaver should
> be torn down
> on receipt of a UDP broadcast).
> 
> [C code cut]
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to