Link to home
Start Free TrialLog in
Avatar of jvh042097
jvh042097

asked on

Password protected screensaver blocks me !!!

i have a program which runs fine (!). I have scheduled it to run every night at 4:00. At that moment, my NTserver is in screen saver mode, password protected. In that case, my program doesn't work right. (i'm using specific OCX's to retrieve real-time financial data from Reuters etc ...). I guess the easiest way to solve the problem will be to desactivate this screen-saving mode via my delphi program. How do I do that ?
Avatar of mirek071497
mirek071497

You must increase priority or write a service. Please test if the screen server make your program very slow or your program can't working.
Hi jvh,

Here is some samplecode to disable your screensaver. This program only renames the screensaver executable so windows can't start the screensaver. Don't forget to enable the screensaver after you finished your program.

Greeting from the Netherlands,

Michiel.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  IniFiles, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  IniFile: TIniFile;

implementation

{$R *.DFM}

procedure DisableScreensaver;
var ScreenSaver : string;
begin
  iniFile := TIniFile.Create('system.ini');
  ScreenSaver := iniFile.ReadString('boot','scrnsave.exe','');
  showMessage(ScreenSaver);
  if ScreenSaver <> '' then begin
    RenameFile(ScreenSaver, ScreenSaver + '_');
  end;
end;

procedure EnableScreensaver;
var ScreenSaver : string;
begin
  iniFile := TIniFile.Create('system.ini');
  ScreenSaver := iniFile.ReadString('boot','scrnsave.exe','');
  showMessage(ScreenSaver);
  if ScreenSaver <> '' then begin
    RenameFile(ScreenSaver + '_', ScreenSaver);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DisableScreensaver;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  EnableScreensaver;
end;

end.


Avatar of jvh042097

ASKER

mes, you are totally wrong ! The Screensaver is already running, in NT there are no ini files (only for 16-bit support), etc. Please think before answering, but anyway thanks !!!!

Mirek, ok but how to do that ? (Creating a Service) ? Isn't there a way to stop the screensaver as one should do it manually by pressing Ctrl-Alt-Del and then introducing a password ?
I'll test anyway to give you  an answer on the last question ...
You are totally wrong !
1. Screensaver is already running (as a service ?)
2. No ini files under NT (only for 16-bit support)

I know procedure SystemParametersInfo, but i don't never test this with protected screensaver.

From MSSDK :

nder Windows NT, you can disable the screen saver from your application
code. To detect if the screen saver is enabled, use this:

   SystemParametersInfo( SPI_GETSCREENSAVEACTIVE,
                         0,
                         pvParam,
                         0
                       );

On return, the parameter pvParam will point to TRUE if the screen saver
setting is enabled in the System control panel applet and FALSE if the
screen saver setting is not enabled.

To disable the screen saver setting, call SystemParametersInfo() with this:

   SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
                         FALSE,
                         0,
                         SPIF_SENDWININICHANGE
                       );


When You using your program in this way your user must be logged on. This is bad idea - try using services.

Here is very fine template for service :

http://www.info-pro.no/sperling/

This is private page of expert Sperling.
indeed a very private page !

i get no access !!!

give me your email so i can mail to you this template.
Jan.Vanhyfte@pophost.eunet.be
I know why you get Access Forbidden,
Directory browsing is forbidden and index.html is not set as default file to show.

(Sorry my bad english)
Jvh,

Assuming that the screen save has NOT YET BEEN activated (you can't start your program if the screen saver is up so it's a moot point) AND that your application is the Top-Most (Active) application then this should work (BTW: I work with Reuters stuff as well :)

In your Private section put:
procedure WMSysCommand(VAR Msg: TWMSysCommand);
                 message WM_SYSCOMMAND;

. . . . .

procedure TForm1.WMSysCommand(VAR Msg: TWMSysCommand);

Begin

 If (Msg.CmdType AND $FFF0) = SC_SCREENSAVE THEN
{Returning a 0 prevents the screen saver from activating}

    Result := 0;  

End;

Now, for the LOW-TECH method...

Disable the screen saver from the control panel and turn the monitor on and off with an electronic timer! Saves tons of headaches! :)

Good luck with your project!
Pegasus
Pegasus, read my question over again : the program i want to execute is scheduled (via an AT-command) to run at 4:00 AM. At that moment, my screensaver-password-protection is running. My program starts up, does 60% of what it is supposed to do, but some other things won't work (connected to the weird ocx's i was talking about). I'm looking for a method of simulating me doing Ctrl-Alt-Del and typing in my password to unlock the screensaver .....
Pegasus, besides, the main function of this screensaver is not the screensaver, but the fact that my NT-session becomes protected after some time. Are you an NT-user anyway ?
Jvh,
Simply put, if my answer is not the one you are looking for then reject it. I have the routine somewhere to simulate the Ctrl-Alt-Del and interact with the password dialog, I'll look it up for you and post it as a COMMENT.

It might be worth noting that the people here are taking time out from other projects to assist you with yours. A little civility would be appreciated.

Pegasus
And yes, my applications (3 commercial and 7 shareware) are designed to work on NT so I guess that qualifies me as a "user"
Hi
I was mail examples of services to you, but I don't know if you need more or mayby other solution. Tell me what you need now.
ASKER CERTIFIED SOLUTION
Avatar of mirek071497
mirek071497

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial