Board index » delphi » Screen Saver - Is it Running under Windows NT ???

Screen Saver - Is it Running under Windows NT ???

I have been playing around with bits of code I have found on the Net - none
of which I have not been able to get working right and am not happy with.
The code isn't reliable and isn't correct.

I need to find out how to tell if the screen saver is running under Windows
NT ?

I think I know how to do this for 95 / 98 - see below.

And, I am not sure about Windows 3.x.

Just hopping someone can set me straight ....  :)

Here is my code so far :
(N.B.  WIN_API_INC___Is_OS_Windows_NT is a function I calls GetVersionEx to
see if NT is running).

Function WIN_API_INC___Is_Screen_Saver_Running : Boolean;
Var
 Scr_Result      : Boolean;
 Is_Running,
 Temp_Val        : Integer;
 WindowHandle    : HWND;
 W1              : LongInt;
 RC              : TRect;
begin
  if (WIN_API_INC___Is_OS_Windows_NT = False) then
  begin
       Temp_Val   := 0;

       Scr_Result := SystemParametersInfo (SPI_SCREENSAVERRUNNING, 0,
@Is_Running, 0);

       SystemParametersInfo (SPI_SCREENSAVERRUNNING, Is_Running, @Temp_Val,
0);

       if (Is_Running = 0) then
          Result := FALSE
       else
          Result := TRUE;
  end

  Else
  begin
       Result := TRUE;

       WindowHandle := GetForegroundWindow();

       if (WindowHandle <> NULL) then
          Result := FALSE;

       w1 := GetWindowLong (WindowHandle, GWL_STYLE);
       if ((w1 AND $F0000000) <> WS_POPUP or WS_VISIBLE) then
          Result := FALSE;

       GetWindowRect (WindowHandle, RC);
       if ((RC.right-rc.left <> GetSystemMetrics (SM_CXSCREEN)) AND
           (RC.bottom-rc.top <> GetSystemMetrics(SM_CYSCREEN)))  Then
          Result := FALSE;
  end;
end;

Hope somebobody can help.

Mike

 

Re:Screen Saver - Is it Running under Windows NT ???


mo...@move.to (Moose) wrote in <8kc68h$c6...@spider.cqu.edu.au>:

Quote

>I have been playing around with bits of code I have found on the Net -
>none of which I have not been able to get working right and am not happy
>with. The code isn't reliable and isn't correct.

>I need to find out how to tell if the screen saver is running under
>Windows NT ?

>I think I know how to do this for 95 / 98 - see below.

I don't have an answer for you, but...

From the Win32 Help file:
SPI_SCREENSAVERRUNNING  Windows 95 only: Used internally; applications
should not use this flag.

--
Ken Rachynski
Database Analyst
EVANS
http://evansonline.com/
ICQ: 61655368

Re:Screen Saver - Is it Running under Windows NT ???


In article <8F6D675DBkrachy...@204.50.1.43>, krac...@evansconsoles.com
says...
Quote
> >I need to find out how to tell if the screen saver is running under
> >Windows NT ?

Check the operating system with GetVersionEx(). If it's NT
(VER_PLATFORM_WIN32_NT) and the screensaver is running, then it's running
under NT.

Under NT4, the screensaver runs in a separate desktop named 'screen
saver' or something similar. Under Win2000 as well, IF password-
protection is enabled. So you could use OpenDesktop() and see if you can
open a desktop of that name.

--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

Other Threads