Solved

Change screensaver-settings in Windows95?

Posted on 1998-11-21
16
260 Views
Last Modified: 2010-04-04
Help me please...

I was wondering how I could change the Windows95 screensaver-settings. For example: I want my Delphi program to change the screensaver-delay (time before screensaver activates) to another value and I even want to change the screensaver itself (pick another screensaver from the available-list). How can I fix this? Please give me good working (clear!) code-examples...

Thank you very much.
RoosieDB
0
Comment
Question by:roosiedb
  • 7
  • 4
  • 3
  • +1
16 Comments
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
All informations about screensaver is in the registry under HKCU\Control Panel\Desktop.
The following code sets the timeout to 600 seconds and the screensaver to MYSAVER.SCR


  Uses Registry;
  With TRegistry.Create Do
  Begin
    OpenKey('Control Panel\Desktop', True);
    WriteString('ScreenSaveTimeOut', '600');
    WriteString('SCRNSAVE.EXE', 'C:\Windows\MYSAVER.SCR');
    Close;
  End;

0
 

Author Comment

by:roosiedb
Comment Utility
Sorry, the code you've made doesn't work...
I have made this project, please tell me what is wrong about it...

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  with TRegistry.Create do
  begin
    OpenKey('Control Panel\Desktop', true);
    WriteString('ScreenSaveTimeOut','999');
    WriteString('SCRNSAVE.EXE','C:\Windows\8fm.scr');
    Close;
  end;
end;

end.

0
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
Hmm, your project is exately like mine! The only error I've found, is that you have to call CloseKey instead of Close. What is the problem, how can you tell it's not working?

BTW. What Delphi version are you using? I'm using D4 and in D4, HKCU is the default rootkey. You can try to add RootKey := HKEY_Current_User after the Create..
0
 

Author Comment

by:roosiedb
Comment Utility
I am using Delphi 3 at Windows 95. Would you please tell me what the code will look like when the HKEY_Current_User is added? And do I have to type SCRNSAVE.EXE just like that, or do I have to fill in the real screensaver-name there also?
Greetings, J.v.Barchum.
0
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
SCRNSAVE.EXE is the keyname, so you'll have to type it just like that..
To use HKCU, insert the line that I wrote in my last comment (RootKey := HKEY_CURRENT_USER) just after TRegistry.Create...
0
 

Author Comment

by:roosiedb
Comment Utility
I added your line but it still doesn't work. When I start the project (and press the BitBtn), the registry seems to be changed (when I look into the registry with cleansweap for example), but the Windows95-configurationscreen (where I normally change the screensaver-values) has not been changed at all, even when I open this configscreen again. The "old" settings are still active... Greetings, J.v.Barchum.
0
 
LVL 2

Expert Comment

by:lortega
Comment Utility
I'm not sure but maybe you need to fire an
WM_WININICHANGE ( for NT ) or  
WM_SETTINGCHANGE ( for Win95 ) message...

good luck,
luis
0
 

Author Comment

by:roosiedb
Comment Utility
OK Iortega, but how can I do that: fire an blablabla message?
Please give me an code-example of it.
Thanx, J.v.Barchum.

BlackMan: Did you make any progress in the meanwhile...?
Also thanks (again).
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:lortega
Comment Utility
Iam sorry but Iam dont have to much time to write code...

After made the change that BlackMan said
you must write somthing like

PostMessage(0,WM_WININICHANGE,0,0);


or to chenge the timeout you can call
systemparametersinfo with SPI_SETSCREENSAVETIMEOUT...

to see the others parameters write systemparametersinfo
in your Delphi editor and pres F1

bye,luis
0
 

Author Comment

by:roosiedb
Comment Utility
Allright, the complete source of my BitBtn-click-procedure looks like this right now...:

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  with TRegistry.Create do
  begin
    RootKey := HKEY_Current_User;
    OpenKey('Control Panel\Desktop', true);
    WriteString('ScreenSaveTimeOut','10');
    WriteString('SCRNSAVE.EXE','c:\windows\8fm.scr');
    PostMessage(0,WM_WININICHANGE,0,0);
    CloseKey;
    Beep;
  end;
end;

But I am very sorry, it still doesn't work...
Was this such a difficult question or am I a stupid Delphi-user?

Greetings,
J.v.Barchum.
0
 
LVL 2

Expert Comment

by:lortega
Comment Utility
If you have another question you have to post as other thread...
0
 

Author Comment

by:roosiedb
Comment Utility
Well it's still the same: I want to change my screensaver-settings by my own Delphi program. But it still doesn't work at all...
0
 
LVL 7

Expert Comment

by:BlackMan
Comment Utility
Hi roosiedb,

Unfortunately, I'm traveling for the next 2 days, if you haven't had an answer when I return on Thursday, I'll look at it again..
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
Roosiedb

The SCRNSAVE.EXE is to be set in the system.ini file you will see it there the reason it is not changing in the registry entry is because the system.ini file is loaded first, to see what I mean goto start, run then type sysedit and press enter click on the system.ini file you will a setting there like SCRNSAVE.EXE=c:\windows\system\3dfx.scr if you change it there it will update the screen saver name, as for the screen saver timeout I will have a look into it for you and let you know tomorrow...

Later
BoRiS
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
Comment Utility
Roosiedb

I took a look at the whole thing and here is the sample code to get the screensaver name and then just write it back to the system.ini file with your screensaver name and then set the timeout for the screen saver, the time out is set in seconds so 120 would be 2 minutes and so on, this will also update straight away...

procedure TForm1.Button1Click(Sender: TObject);
var
ScrIni: TIniFile;
 ScrName: String;
begin
 ScrIni := TiniFile.Create('c:\windows\system.ini');
  ScrName := ScrIni.ReadString('boot', 'SCRNSAVE.EXE', '');
   Edit1.Text := ScrName;//this will give you the current screensaver name
 ScrIni.Free;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Timeout: Integer;
begin
 SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, @Timeout, 0);//this will retrieve the current timeout
  Edit1.Text := IntToStr(Timeout);//this will display the current secounds in the edit1box
end;

procedure TForm1.Button3Click(Sender: TObject);
var
 TimeOut: Integer;
begin
 TimeOut := StrToInt(Edit1.Text);//this will be the new value in the edit1box eg 120 for 2 min.
  SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, Timeout, nil, SPIF_SENDCHANGE);// this will change the time out to the new value
end;

also remember to add Inifiles to your uses clause...
uses
Windows, Forms,..., IniFiles;

I f you want me to send the application that this comes from to you just leave your email address..

Later
BoRiS
0
 

Author Comment

by:roosiedb
Comment Utility
OK Boris, Please let me know when you have the whole answer to my question. Thanx very much for helping. J.v.Barchum.
0

Featured Post

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.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

6 Experts available now in Live!

Get 1:1 Help Now