Solved

Change screensaver-settings in Windows95?

Posted on 1998-11-21
16
273 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
ID: 1347511
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
ID: 1347512
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
ID: 1347513
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:roosiedb
ID: 1347514
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
ID: 1347515
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
ID: 1347516
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
ID: 1347517
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
ID: 1347518
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
 
LVL 2

Expert Comment

by:lortega
ID: 1347519
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
ID: 1347520
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
ID: 1347521
If you have another question you have to post as other thread...
0
 

Author Comment

by:roosiedb
ID: 1347522
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
ID: 1347523
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
ID: 1347524
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
ID: 1347525
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
ID: 1347526
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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