View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Apr 17, 2007 11:35 pm Post subject: Desktop Folder |
|
|
I know where to change the location of the desktop folder in the registry, but is there a way to broadcast that change to the system to see the change without rebooting?
Thanks _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 12:55 am Post subject: |
|
|
LiquidCode,
You could try sending a WM_USERCHANGED or WM_SETTINGCHANGE message to all top level windows.
Code: |
%%WM_SETTINGCHANGE = 26
%%WM_USERCHANGED = 84
%%HWND_BROADCAST = "%"65535
%A = @SendMsg(%%HWND_BROADCAST,%%WM_USERCHANGED,0,0)
%B = RegistryNameThatYouChanged
%A = @SendMsg(%%HWND_BROADCAST,%%WM_SETTINGCHANGE,0,@addr("%B"))
|
_________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 1:28 am Post subject: |
|
|
I tried those messages above and they did not work. I think the only other option would be to stop and start the shell. I have posted this code before but here it goes again.
Code: |
Title Stop windows shell
#DEFINE COMMAND,STOPSHELL,STARTSHELL
LoadLib user32.dll
LoadLib kernel32.dll
StopShell
Wait 25
StartShell
FreeLib user32
FreeLib kernel32
STOP
:stopshell
%A = @winexists(#Progman)
If %A
%%WM_QUIT = 18
%B = @lib(user32,PostMessageA,DWORD:,@Strdel(%A,1),%%WM_QUIT,0,0)
End
Exit %B
:startshell
%%SW_SHOW = 5
%S = @lib(kernel32,WinExec,DWORD:,Explorer.exe,DWORD:%%SW_SHOW)
Exit %S
|
The idea here is that since the registry key in question is an Explorer key that if you stop and start Explorer you should force Windows Shell to read the registry key again. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 2:04 am Post subject: |
|
|
LiquidCode,
Just to let you know. The proper way to change the path to a special folder is to use the SHSetFolderPathA ordinal #231 function in the shell32.dll. You will not be able to use the VDS @lib() function to call this funtion since it cannot call functions by ordinal. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Apr 18, 2007 2:19 am Post subject: |
|
|
Doh, I guess just changing the registry entry to a different path will not work... Can GadgetX.dll set a new folder? Can you whip some quick code up? _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 2:46 am Post subject: |
|
|
Your wish is my command...
Code: |
#-----------------------------------------------------------------------------#
# #
# Demo showing how to use the SHSetFolderPathA shell32.dll function #
# CSIDL constant values can be found at the URL below #
# http://msdn2.microsoft.com/en-us/library/ms649274.aspx #
# #
# Author: Johnny Kinsey #
# #
# Copyright: Copyright © 2007 Dragon Sphere Software #
# #
# NOTE: If changing the path to the My Documents folder you will probably #
# want to change the My Pictures, My Music, and Favorites folders as #
# well since these are usually located under the users My Documents #
# folder. #
#-----------------------------------------------------------------------------#
External GadgetX.dll,5.0
#DEFINE COMMAND,DEFINE,SET,CALL,FREEDLL
#DEFINE FUNCTION,GET,CALL,LOADDLL,OR,AND
Define Variable,Handle,shell32
Set shell32,@LoadDLL(shell32.dll)
# This constant did not work for me
Define Constant,CSIDL_MYDOCUMENTS,$000C
# This constant works for the My Documents folder on my Windows XP SP2 with shell32.dll ver. 6.0
Define Constant,CSIDL_PERSONAL,$0005
# Ensures expanding of environment variables.
Define Constant,CSIDL_FLAG_DONT_UNEXPAND,$2000
Define Function,HRESULT,shell32,#231,SHSetFolderPathA,INTEGER|CSIDL,DWORD|hToken,DWORD|dwFlags,String|pszPath
%B = D:\My Documents
%A = @Call(SHSetFolderPathA,@Or(CSIDL_PERSONAL,CSIDL_FLAG_DONT_UNEXPAND),0,0,%B)
If @Zero(%A)
Info Your My Documents folder should point to %B
Else
Info Something is wrong %A
End
FreeDLL shell32
|
You will still have the same issue as changing the registry key however you will be able to target the shell directories easier. So you just might need to restart the shell to get everything to update properly. Also any program that uses the SHGetSpecialFolderPath or any of the Shell Get functions that pertain to shell folders will pick up this new path without the restart or reboot. VDS however reads the registry to retrieve the folder locations. Don't ask me why it does that but I guess Jules has his reasons _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Apr 18, 2007 3:09 am Post subject: |
|
|
Cool Thanks. Do I just change Personal to Desktop if I want to change the desktop? I'm going to give it a try and find out.... oh BTW, I am using Vista so we'll find out if it works on here. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 3:10 am Post subject: |
|
|
LiquidCode,
If you don't want to predefine the function and would like code that looks similar to the VDS @lib() function... Try this out it's the same as above but things can be done inline and may be a bit more logical to follow.
Code: |
#-----------------------------------------------------------------------------#
# #
# Demo showing how to use the SHSetFolderPathA shell32.dll function #
# CSIDL constant values can be found at the URL below #
# http://msdn2.microsoft.com/en-us/library/ms649274.aspx #
# #
# Author: Johnny Kinsey #
# #
# Copyright: Copyright © 2007 Dragon Sphere Software #
# #
# NOTE: If changing the path to the My Documents folder you will probably #
# want to change the My Pictures, My Music, and Favorites folders as #
# well since these are usually located under the users My Documents #
# folder. #
#-----------------------------------------------------------------------------#
External GadgetX.dll,5.0
#DEFINE COMMAND,DEFINE,SET,CALL,FREEDLL
#DEFINE FUNCTION,GET,CALL,LOADDLL,OR,AND,GETFUNCPTR,CALLFUNCPTR
# define a variable to hold the handle of the shell32.dll
Define Variable,Handle,shell32
# This constant did not work for me
Define Constant,CSIDL_MYDOCUMENTS,$000C
# This constant works for the My Documents folder on my Windows XP SP2 with shell32.dll ver. 6.0
Define Constant,CSIDL_PERSONAL,$0005
# Ensures expanding of environment variables.
Define Constant,CSIDL_FLAG_DONT_UNEXPAND,$2000
# Define a pointer for the address of the SHSetFolderPathA function
Define Variable,Pointer,SHSetFolderPathA
# Load the shell32.dll
Set shell32,@LoadDLL(shell32.dll)
# Get a pointer to the SHSetFolderPathA function using the ordinal number and assign it to our pointer variable.
Set SHSetFolderPathA,@GetFuncPtr(shell32,#231)
# The path of our new My Documents folder.
%B = D:\My Documents
# Call the SHSetFolderPathA function
%A = @CallFuncPtr(HRESULT,SHSetFolderPathA,INTEGER|@Or(CSIDL_PERSONAL,CSIDL_FLAG_DONT_UNEXPAND),DWORD|0,DWORD|0,STRING|%B)
If @Zero(%A)
# If the value is equal to S_OK = $00000000 = Zero
Info Your My Documents folder should point to %B
Else
# if there is a problem we get E_INVALIDARG = $80070057
# Several error conditions cause the return of this value, including the following:
# The csidl value is not valid.
# The csidl value does not refer to a virtual folder.
# The csidl value does not refer to a system folder.
# The csidl value refers to a folder that cannot be renamed or moved.
# The dwFlags value is not 0 (zero).
# The pszPath value is NULL.
# The string pointed to by pszPath value is an empty string ("") of length zero.
Info Something is wrong %A
End
# Free the shell32.dll
FreeDLL shell32
|
_________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 3:17 am Post subject: |
|
|
UPDATED wrong constant definition... It's fixed now.
LiquidCode wrote: | Cool Thanks. Do I just change Personal to Desktop if I want to change the desktop? |
Here is the constant for the Desktop folder...
Code: |
Define Constant,CSIDL_DESKTOPDIRECTORY,$0010
|
I am not sure if this will work? I have never tried changing the physical location of the desktop for a user before. You will probably need to copy all the links and everything over to the new desktop location? Vista might freak out moving around it's desktop folder. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Apr 18, 2007 3:24 am Post subject: |
|
|
It worked!! Thanks. I am making app that allows to change the desktop. I am mainly making it for myself, but if it turns out good, I may just release it. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Wed Apr 18, 2007 3:26 am Post subject: |
|
|
Wow I am surprised that it worked in Vista with all of Vista's security _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Wed Apr 18, 2007 3:37 am Post subject: |
|
|
Yeah. I can even change the desktop to the ROOT of a drive. Changing the desktop in Vista doesn't let me do that, only to a folder. _________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|