Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@REGSETENV question

Aug
1,916
68
Hi,
I'm using;

TCC 11.00.50 Windows XP [Version 5.1.2600]
TCC Build 50 Windows XP Build 2600 Service Pack 3

I want to change the Desktop Wallpaper from a batch file. I do this with the following;

Code:
echo %@regsetenv["HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",REG_SZ,c:\utils\nasapic.bmp]
I run REGEDIT.EXE and see that the change has indeed been made.

According to the help file,

"a broadcast message is sent to all applications when the change is made, so that any application monitoring such messages can respond to the change immediately if it is designed to do so."

Well, the wallpaper does not change. I have tried the following after making the registry change;

Code:
RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
but it does not force the change.

If I logoff, and then logon, the wallpaper changes to the .BMP I had placed into the registry.

I can resort to using SetWallPaper from Optimum X, but I would like to keep my reliance on external apps to a minimum.

Is REGSETENV supposed to tell Windows that I have made the change, or am I misunderstanding?

Joe
 
On Thu, 01 Jul 2010 15:31:01 -0400, Joe Caverly
<> wrote:

|I want to change the Desktop Wallpaper from a batch file. I do this with the following;
|
|
|Code:
|---------
|echo %@regsetenv["HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",REG_SZ,c:\utils\nasapic.bmp]
|---------
|I run REGEDIT.EXE and see that the change has indeed been made.
|
|According to the help file,
|
|"a broadcast message is sent to all applications when the change is made, so that any application monitoring such messages can respond to the change immediately if it is designed to do so."
|
|Well, the wallpaper does not change. I have tried the following after making the registry change;

I suspect TCC is broadcasting the WM_SETTINGCHANGE/WM_WININICHANGE
message. I don't know if it's possible to effect a wallpaper change
with that message, but even if it were, the message would need to be
accompanied to two very specific parameters and it would be impossible
for TCC to figure out what they are. See

http://msdn.microsoft.com/en-us/library/ms725497%28VS.85%29.aspx

I googled a script that suggests this command

%SystemRoot%\System32\RUNDLL32.EXE user32.dll,
UpdatePerUserSystemParameters

(without the extra parameters you mentioned). I also found an
additional "1, TRUE" or "1, FALSE" recommended.
 
I think that Explorer only reads that registry value at startup. You could TASKEND /F and restart Explorer.exe, but a nicer approach would be to use SystemParametersInfo():

Code:
alias wallpaper=`echo %@if[%@winapi[user32.dll,SystemParametersInfo,20,0,%@if[%# gt 0,%1,NULL],2] == 0,Failed.,Okay.]`
Pass it a filename: .BMP only, no .JPG. If you want to use a .JPG, you'll have to convert it to a .BMP first. If you pass a 0 or the word NULL instead, the desktop will revert to your default wallpaper -- the one stored in that registry value.
 
Note to Rex: The alias in the above post doesn't work for me if I use 0x001f instead of 20. Is @WINAPI supposed to support hex integers?
 
@REGSETENV

I can't answer the specific issue you are seeing, however I can suggest an
alternative approach.

'Constants for changing wallpaper with SystemParametersInfo
Const SPIF_UPDATEINIFILE = &H1
Const SPI_SETDESKWALLPAPER = 20
Const SPIF_SENDWININICHANGE = &H2
Success = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, m_sFileName,
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE)

So using the @WINAPI call (not supported in TCC/LE) you would:

echo %@winapi[user32.dll,SystemParametersInfoW,20,0,"c:\utils\nasapic.bmp
",3]

-Scott

Joe Caverly <> wrote on 07/01/2010 03:31:00 PM:


> Hi,
> I'm using;
>
> TCC 11.00.50 Windows XP [Version 5.1.2600]
> TCC Build 50 Windows XP Build 2600 Service Pack 3
>
> I want to change the Desktop Wallpaper from a batch file. I do this
> with the following;
>
>
> Code:
> ---------
> echo %@regsetenv["HKEY_CURRENT_USER\Control
> Panel\Desktop\Wallpaper",REG_SZ,c:\utils\nasapic.bmp]
> ---------
> I run REGEDIT.EXE and see that the change has indeed been made.
>
> According to the help file,
>
> "a broadcast message is sent to all applications when the change is
> made, so that any application monitoring such messages can respond
> to the change immediately if it is designed to do so."
>
> Well, the wallpaper does not change. I have tried the following
> after making the registry change;
>
> RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
>
> but it does not force the change.
>
> If I logoff, and then logon, the wallpaper changes to the .BMP I had
> placed into the registry.
>
> I can resort to using SetWallPaper from http://www.optimumx.com/,
> but I would like to keep my reliance on external apps to a minimum.
>
> Is REGSETENV supposed to tell Windows that I have made the change,
> or am I misunderstanding?
>
> Joe
>
>
>
>
 
On Thu, 01 Jul 2010 16:45:16 -0400, Charles Dye
<> wrote:

|Note to Rex: The alias in the above post doesn't work for me if I use 0x001f instead of 20. Is @WINAPI supposed to support hex integers?

I wouldn't expect 0x001f to be equivalent to 20 under any
circumstances. :-)
 

Similar threads

Back
Top