SHSetFolderPath CSIDL_DESKTOP & CSIDL_DRIVES

SHSetFolderPath CSIDL_DESKTOP & CSIDL_DRIVES - Delphi/Pascal - Programmation

Marsh Posté le 10-09-2006 à 17:52:54    

Bonjour a tous,
 
J'ai un bout de code permettant d'expoiter la fonction SHSetFolderPath permet de changer à chaud le chemin des répértoire system.
Il fonctionne tres bien pour changer:
CSIDL_TEMPLATES  
CSIDL_FAVORITES
CSIDL_APPDATA
CSIDL_PERSONAL
CSIDL_DESKTOPDIRECTORY
CSIDL_STARTMENU
CSIDL_PROGRAMS
 
mais impossible de le faire fonctionner avec:
CSIDL_DESKTOP
CSIDL_DRIVES
 
J'en ai besoin pour changer le chemin du bureau (CSIDL_DESKTOP) sans redamarrer explorer.
Le voici ci-dessous ; Pouvez-vous m'aider ?
 
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls,shlobj;
 
type
  TForm1 = class(TForm)
  Button1: TButton;
  procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
 
var
Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
 FLibHandle: THandle;
 path:WideString;
 SHSetFolderPath: FUNCTION (csidl:integer;
 hToken:THANDLE;
 dwFlags: DWORD;
 pszPath: LPCTSTR):HRESULT;stdcall;
begin
  FLibHandle := LoadLibrary('Shell32.dll');
  SHSetFolderPath := GetProcAddress(FLibHandle, pchar(Ord(232)));  
  path:='C:\Mon Répertoire';
  if assigned(SHSetFolderPath)
  then try
    if not SUCCEEDED(SHSetFolderPath(CSIDL_FAVORITES, 0, 0, pchar(path)))then beep;
    finally
  end;
  if FLibHandleB <> 0 then FreeLibrary(FLibHandle);
end;
 
end.

Reply

Marsh Posté le 10-09-2006 à 17:52:54   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed