Solved

Password protected screensaver blocks me !!!

Posted on 1997-10-23
16
272 Views
Last Modified: 2010-04-04
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 ?
0
Comment
Question by:jvh042097
  • 6
  • 6
  • 2
  • +2
16 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348640
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.
0
 

Expert Comment

by:mes
ID: 1348641
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.


0
 

Author Comment

by:jvh042097
ID: 1348642
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 ...
0
 

Author Comment

by:jvh042097
ID: 1348643
You are totally wrong !
1. Screensaver is already running (as a service ?)
2. No ini files under NT (only for 16-bit support)

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348644
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
                       );


0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348645
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.
0
 

Author Comment

by:jvh042097
ID: 1348646
indeed a very private page !

i get no access !!!

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348647
give me your email so i can mail to you this template.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:jvh042097
ID: 1348648
Jan.Vanhyfte@pophost.eunet.be
0
 

Expert Comment

by:chrb
ID: 1348649
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)
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1348650
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
0
 

Author Comment

by:jvh042097
ID: 1348651
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 .....
0
 

Author Comment

by:jvh042097
ID: 1348652
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 ?
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1348653
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"
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1348654
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.
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 200 total points
ID: 1348655
Mayby I can submit answer ?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now