Solved

Change screensaver-settings in Windows95?

Posted on 1998-11-21
16
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Process Javascript errors with Delphi TWebBrowser 1 210
Delphi - replicating a form 8 93
Reconfigure Delphi Install? 2 65
Convert MS Word document to a PDF file 9 115
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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