uses ShellApi; var DriveRoot: string; ExplorerHandle: HWND; FoundDir: Boolean; function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall; const MyMaxName = 64; MyMaxText = 64; var ParamChild: Integer; ClassName: string; WindowText: string; begin Result := True; SetLength(ClassName, MyMaxName); SetLength(ClassName, GetClassName(Wnd, PChar(ClassName), MyMaxName)); SetLength(WindowText, MyMaxText); SetLength(WindowText, SendMessage(Wnd, WM_GETTEXT, MyMaxText, lParam(PChar(WindowText)))); if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') then begin if ClassName = 'ExploreWClass'then begin ExplorerHandle := Wnd; EnumChildWindows(Wnd, @EnumWindowsProc, ParamChild); end; if Pos(DriveRoot, WindowText) = 1 then begin FoundDir := True; ShowWindow(ExplorerHandle, SW_RESTORE); BringWindowToTop(ExplorerHandle); end; end; end; function BringToTopIfRuns(Drive: string): Boolean; var Param: Integer; begin DriveRoot := Drive; FoundDir := False; EnumWindows(@EnumWindowsProc, Param); Result := FoundDir; end;
var Drive: string; begin Drive := 'D:\'; if not BringToTopIfRuns(Drive) then ShellExecute(Handle, 'explore', PChar(Drive), nil, nil, SW_SHOW); end;
uses ShellApi; var SearchDir: string; ExplorerHandle: HWND; FoundDir: Boolean; function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall; const MyMaxName = 64; MyMaxText = 64; var ParamChild: Integer; ClassName: string; WindowText: string; begin Result := True; SetLength(ClassName, MyMaxName); SetLength(ClassName, GetClassName(Wnd, PChar(ClassName), MyMaxName)); SetLength(WindowText, MyMaxText); SetLength(WindowText, SendMessage(Wnd, WM_GETTEXT, MyMaxText, lParam(PChar(WindowText)))); if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') then begin if ClassName = 'ExploreWClass'then begin ExplorerHandle := Wnd; EnumChildWindows(Wnd, @EnumWindowsProc, ParamChild); end; if Pos(SearchDir, WindowText) = 1 then begin FoundDir := True; ShowWindow(ExplorerHandle, SW_RESTORE); BringWindowToTop(ExplorerHandle); end; end; end; function BringToTopIfRuns(Dir: string): Boolean; var Param: Integer; begin SearchDir := Dir; FoundDir := False; EnumWindows(@EnumWindowsProc, Param); Result := FoundDir; end;
var SaveDir: string; begin SaveDir := 'D:\Sauvegarde'; if not BringToTopIfRuns(SaveDir) then ShellExecute(Handle, 'explore', PChar(SaveDir), nil, nil, SW_SHOW); end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var
DriveRoot: string;
ExplorerHandle: HWND;
FoundDir: Boolean;
function BringToTopIfRuns(Drive: string): Boolean;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Drive: string;
begin
Drive := 'D:\';
if not BringToTopIfRuns(Drive) then
ShellExecute(Handle, 'explore', PChar(Drive), nil, nil, SW_SHOW);
end;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
const
MyMaxName = 64;
MyMaxText = 64;
var
ParamChild: Integer;
ClassName: string;
WindowText: string;
begin
Result := True;
SetLength(ClassName, MyMaxName);
SetLength(ClassName, GetClassName(Wnd, PChar(ClassName), MyMaxName));
SetLength(WindowText, MyMaxText);
SetLength(WindowText, SendMessage(Wnd, WM_GETTEXT, MyMaxText, lParam(PChar(WindowText))));
if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') then
begin
if ClassName = 'ExploreWClass'then
begin
ExplorerHandle := Wnd;
EnumChildWindows(Wnd, @EnumWindowsProc, ParamChild);
end;
if Pos(DriveRoot, WindowText) = 1 then
begin
FoundDir := True;
ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
function BringToTopIfRuns(Drive: string): Boolean;
var
Param: Integer;
begin
DriveRoot := Drive;
FoundDir := False;
EnumWindows(@EnumWindowsProc, Param);
Result := FoundDir;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SearchDir: string;
ExplorerHandle: HWND;
FoundDir: Boolean;
function BringToTopIfRuns(Dir: string): Boolean;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Drive: string;
begin
Drive := 'D:\';
if not BringToTopIfRuns(Drive) then
ShellExecute(Handle, 'explore', PChar(Drive), nil, nil, SW_SHOW);
end;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
const
MyMaxName = 64;
MyMaxText = 64;
var
ParamChild: Integer;
ClassName: string;
WindowText: string;
begin
Result := True;
SetLength(ClassName, MyMaxName);
SetLength(ClassName, GetClassName(Wnd, PChar(ClassName), MyMaxName));
SetLength(WindowText, MyMaxText);
SetLength(WindowText, SendMessage(Wnd, WM_GETTEXT, MyMaxText, lParam(PChar(WindowText))));
if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') then
begin
if ClassName = 'ExploreWClass'then
begin
ExplorerHandle := Wnd;
EnumChildWindows(Wnd, @EnumWindowsProc, ParamChild);
end;
if Pos(SearchDir, WindowText) = 1 then
begin
FoundDir := True;
ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
function BringToTopIfRuns(Dir: string): Boolean;
var
Param: Integer;
begin
SearchDir := Dir;
FoundDir := False;
EnumWindows(@EnumWindowsProc, Param);
Result := FoundDir;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls, StrUtils;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SearchDir: string;
ExplorerHandle: HWND;
FoundDir: Boolean;
function BringToTopIfRuns(Dir: string): Boolean;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
SaveDir: string;
NewDir: string;
begin
SaveDir := 'D:\Autres';
NewDir := reversestring (SaveDir);
NewDir := leftStr(NewDir, pos('\',NewDir)-1);
NewDir := reversestring (NewDir);
form1.Caption:=NewDir;
if not BringToTopIfRuns(NewDir) then
ShellExecute(Handle, 'explore', PChar(SaveDir), nil, nil, SW_SHOW);
end;
function EnumWindowsProc(Wnd: HWND; var V): BOOL; stdcall;
const
MyMaxName = 64;
MyMaxText = 64;
var
ParamChild: Integer;
ClassName: string;
WindowText: string;
begin
Result := True;
SetLength(ClassName, MyMaxName);
SetLength(ClassName, GetClassName(Wnd, PChar(ClassName), MyMaxName));
SetLength(WindowText, MyMaxText);
SetLength(WindowText, SendMessage(Wnd, WM_GETTEXT, MyMaxText, lParam(PChar(WindowText))));
if (ClassName = 'CabinetWClass') or (ClassName = 'ToolBarWindow32') then
begin
if ClassName = 'CabinetWClass'then
begin
ExplorerHandle := Wnd;
EnumChildWindows(Wnd, @EnumWindowsProc, ParamChild);
end;
if Pos(SearchDir, WindowText) = 1 then
begin
FoundDir := True;
ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
function BringToTopIfRuns(Dir: string): Boolean;
var
Param: Integer;
begin
SearchDir := Dir;
FoundDir := False;
EnumWindows(@EnumWindowsProc, Param);
Result := FoundDir;
end;
end.
procedure TForm1.Button1Click(Sender: TObject);
var
SaveDir: string;
NewDir: string;
begin
SaveDir := 'D:\Autres\';
NewDir := SaveDir;
NewDir := reversestring (NewDir);
if NewDir[1]='\' then delete(NewDir,1,1);
NewDir := leftStr(NewDir, pos('\',NewDir)-1);
NewDir := reversestring (NewDir);
form1.Caption:=NewDir;
if not BringToTopIfRuns(NewDir) then
ShellExecute(Handle, 'explore', PChar(SaveDir), nil, nil, SW_SHOW);
end;
function EnumWindowsProc(Hwnd: HWND; lParam: LPARAM): BOOL; stdcall;@+
var
CutAdress : string;
ClassName : array[0..MAX_PATH] of Char;
WindowText: array[0..MAX_PATH] of Char;
begin
Result := True;
GetClassName(Hwnd, ClassName, MAX_PATH);
GetWindowText(Hwnd, WindowText, MAX_PATH);
if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') or (ClassName = 'CabinetWClass') or (ClassName = 'ToolbarWindow32') then
begin
if (ClassName = 'ExploreWClass') or (ClassName = 'CabinetWClass') then
begin
ExplorerHandle := Hwnd;
EnumChildWindows(Hwnd, @EnumWindowsProc, 0);
end;
if ((ClassName = 'ToolbarWindow32') and (WindowText <> EmptyStr)) or (Pos(DriveRoot, WindowText) = 1) then
begin
CutAdress := WindowText;
if Pos('Adresse', WindowText) = 1 then
CutAdress := Copy(WindowText, 11, Length(WindowText));
if Pos(DriveRoot, CutAdress) = 1 then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
end;
function BringToTopIfRuns(Drive: string): Boolean;
begin
DriveRoot := Drive;
FoundDir := False;
EnumWindows(@EnumWindowsProc, 0);
Result := FoundDir;
end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
if Pos('Adresse', WindowText) = 1 then
CutAdress := Copy(WindowText, 11, Length(WindowText));
if Pos(DriveRoot, CutAdress) = 1 then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
if Pos(SearchDir, CutAdress) > 0 then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
function EnumWindowsProc(Hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
CutAdress : string;
ClassName : array[0..MAX_PATH] of Char;
WindowText: array[0..MAX_PATH] of Char;
begin
Result := True;
GetClassName(Hwnd, ClassName, MAX_PATH);
GetWindowText(Hwnd, WindowText, MAX_PATH);
if WindowText<>'' then Form1.Memo1.Lines.Add(WindowText);
if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') or (ClassName = 'CabinetWClass') or (ClassName = 'ToolbarWindow32') then
begin
if (ClassName = 'ExploreWClass') or (ClassName = 'CabinetWClass') then
begin
ExplorerHandle := Hwnd;
EnumChildWindows(Hwnd, @EnumWindowsProc, 0);
end;
if ((ClassName = 'ToolbarWindow32') and (WindowText <> EmptyStr)) or (Pos(SearchDir, WindowText) = 1) then
begin
Form1.Memo2.Lines.Add(WindowText);
CutAdress := WindowText;
CutAdress:=reversestring (CutAdress);
CutAdress:=leftStr(CutAdress, pos('\:',CutAdress)+2);
CutAdress:=reversestring (CutAdress);
form1.caption:=CutAdress;
if SearchDir=CutAdress then
begin
Form1.Memo3.Lines.Add(CutAdress);
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
end;
if ((ClassName = 'ToolbarWindow32') and (WindowText <> EmptyStr)) or (Pos(SearchDir, WindowText) <> 0) then@+
begin
CutAdress := Copy(WindowText, Pos(SearchDir, WindowText), Length(WindowText));
if SearchDir = CutAdress then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls, StrUtils;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
SearchDir: string;
ExplorerHandle: HWND;
FoundDir: Boolean;
function BringToTopIfRuns(Drive: string): Boolean;
function EnumWindowsProc(Hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
SaveDir: string;
begin
SaveDir := 'D:\Autres\';
SaveDir := reversestring (SaveDir);
if SaveDir[1]='\' then delete(SaveDir,1,1);
SaveDir := reversestring (SaveDir);
if not BringToTopIfRuns(SaveDir) then
ShellExecute(Handle, 'explore', PChar(SaveDir), nil, nil, SW_SHOW);
end;
function EnumWindowsProc(Hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
CutAdress : string;
ClassName : array[0..MAX_PATH] of Char;
WindowText: array[0..MAX_PATH] of Char;
begin
Result := True;
GetClassName(Hwnd, ClassName, MAX_PATH);
GetWindowText(Hwnd, WindowText, MAX_PATH);
if (ClassName = 'ExploreWClass') or (ClassName = 'ComboBoxEx32') or (ClassName = 'CabinetWClass') or (ClassName = 'ToolbarWindow32') then
begin
if (ClassName = 'ExploreWClass') or (ClassName = 'CabinetWClass') then
begin
ExplorerHandle := Hwnd;
EnumChildWindows(Hwnd, @EnumWindowsProc, 0);
end;
if ((ClassName = 'ToolbarWindow32') and (WindowText <> EmptyStr)) or (Pos(SearchDir, WindowText) <> 0) then
begin
CutAdress := Copy(WindowText, Pos(SearchDir, WindowText), Length(WindowText));
if SearchDir = CutAdress then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;
end;
end;
end;
function BringToTopIfRuns(Drive: string): Boolean;
begin
SearchDir := Drive;
FoundDir := False;
EnumWindows(@EnumWindowsProc, 0);
Result := FoundDir;
end;
end.