Solved

Change screensaver-settings in Windows95?

Posted on 1998-11-21
16
267 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 92
Simple Delphi Question 9 83
Find and Replace Stream with 0s 8 56
Delphi...Split view - idea? 1 39
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 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

5 Experts available now in Live!

Get 1:1 Help Now