Un repertoire est-il deja ouvert par l'explorer de windows ?

Résolu
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014 - 20 févr. 2014 à 10:46
korgis Messages postés 420 Date d'inscription samedi 17 mai 2003 Statut Membre Dernière intervention 6 mai 2019 - 25 févr. 2014 à 11:53
Bonjour,

Pour un programme réalisant des mesures, je demande a l'opérateur de me fournir un dossier de sauvegarde pour les fichiers générés.
Une fois les mesures lancées, j'ouvre le répertoire de destination (pour faciliter l'accès aux fichiers) avec la fonction :

ShellExecute(Handle,'explore',PChar('D:\'),nil,nil,SW_SHOW)

Mais si l'opérateur relance le programme avec le même répertoire de destination, le programme va ouvrir une nouvelle fenêtre explorer de ce répertoire.

Existe il une solution, pour savoir si une fenêtre explorer de mon répertoire est déjà ouverte et si oui la passer au premier plan ?

Par avance merci pour vos solutions.


PS: Windows 7, delphi 2007

7 réponses

korgis Messages postés 420 Date d'inscription samedi 17 mai 2003 Statut Membre Dernière intervention 6 mai 2019 17
22 févr. 2014 à 00:14
Hello.

Bon, puisque personne ne s'y risque, je me jette.

La programmation Windows, c'est pas trop mon fort...
Or le problème est intéressant, et je n'ai trouvé de solution nulle part.
Et j'ai cherché un bon moment !

Après avoir rassemblé un peu de doc, je m'y suis donc attelé.

J'ai utilisé la procedure CallBack EnumWindowsProc faisant appel à l'api Win32, qui m'a donné un peu de fil à retordre.
Après avoir pas mal bidouillé, voici au final deux codes qui fonctionnent :

- le premier prend en paramètre le lecteur où est stockée la sauvegarde, quel que soit le répertoire ouvert sur le lecteur où se trouve la sauvegarde;
- le deuxième prend en paramètre le chemin exact de la sauvegarde, donc ouvrira à nouveau l'explorateur même si c'est le même lecteur, mais pas le bon répertoire.

Il faudra choisir en fonction de l'effet recherché.

1er code :

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;


exemple d'utilisation :

var
  Drive: string;
begin
  Drive := 'D:\';
  if not BringToTopIfRuns(Drive) then
    ShellExecute(Handle, 'explore', PChar(Drive), nil, nil, SW_SHOW);
end;


2eme code :

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;


et exemple d'utilisation :

var
  SaveDir: string;
begin
  SaveDir := 'D:\Sauvegarde';
  if not BringToTopIfRuns(SaveDir) then
    ShellExecute(Handle, 'explore', PChar(SaveDir), nil, nil, SW_SHOW);
end;


et voilà...
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
24 févr. 2014 à 08:16
Bonjour Korgis, et merci de t'être penche sur le sujet.

J'ai essaye tes 2 propositions, mais elles ne fonctionnent pas chez moi : ouverture du répertoire dans une nouvelle fenêtre explorer a chaque fois que je clique sur le bouton même si une fenêtre est déjà ouverte.

J'ai peut être loupé quelque chose.
Voici les codes que j'ai utilisés (une form et un bouton)

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.

et pour le 2eme

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.
0
korgis Messages postés 420 Date d'inscription samedi 17 mai 2003 Statut Membre Dernière intervention 6 mai 2019 17
24 févr. 2014 à 11:13
Salut,
Ce code, je l'avais compilé sous D4 et D7 et testé sous XP pro sp3, ça marchait nickel. Je viens de revérifier, no problem.
Par contre, je viens de tester sous 8.1 : ça ouvre une nouvelle fenêtre à chaque fois...
Pareil que sous Windows 7, je suppose.
Au fait, j'avais tellement le nez dans la bulle, je n'ai même pas fait attention que je balançais 2 fois le même code, la différence étant dans la manière de passer le paramètre, racine du lecteur ou chemin de répertoire.
Sinon, ça marche vraiment trop bien sous XP... :-P
Vraiment désolé.
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
24 févr. 2014 à 11:21
OK, merci de l'info.
Si quelqu'un a une solution pour WINDOWS 7, je suis preneur.
0
cs_yanb Messages postés 271 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 7 juillet 2022 14
24 févr. 2014 à 14:28
Salut,
la solution est la bonne mais il faut utiliser d'autre ClassName avec Windows 7 ;) , la classe CabinetWClass et ensuite ToolBarWindow32 ou ShellTabWindowClass pour avoir le nom long ou court...j'essaierai de poser un bout de code dans un moment ( Sauf si Korgis si colle avec mes infos :P )
@+
0
korgis Messages postés 420 Date d'inscription samedi 17 mai 2003 Statut Membre Dernière intervention 6 mai 2019 17
24 févr. 2014 à 15:24
Rhôôô...
Bien vu, yanb !
Vas-y, je te laisse la main... ;-)
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
24 févr. 2014 à 15:25
solution trouvée: le problème venait du fait que l'on cherchait une fenêtre avec 'D:\Autres' or Win7 affiche la fenêtre avec le nom du répertoire : il faut donc décomposer "SaveDir" pour n'avoir que 'Autres'
et remplacer 'ExploreWClass' par 'CabinetWClass' (merci cs_yanb)

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.



dites moi si ça marche chez vous et je ferme le sujet

--
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
24 févr. 2014 à 15:59
Pour être un peu plus complet, si 'SaveDir' est issue d'un "ExtractFilePath" (dernier caractere : '\', contrairement au "ExtractFileDir") :


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;
0
cs_yanb Messages postés 271 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 7 juillet 2022 14
24 févr. 2014 à 16:02
Le code 1 de Korgis avec les modifs, j'ai essayé de garder la compatibilité XP, W7 ;-) on peut probablement simplifié encore...
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;
@+
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
24 févr. 2014 à 16:20
Merci a vous deux.
0
cs_yanb Messages postés 271 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 7 juillet 2022 14
24 févr. 2014 à 16:51
De rien, par contre petite précision sur le code que tu proposes...
Il ne fonctionne pas dans tous les cas de vigures, imaginons que tu as un répertoire 'D:\Autres' ouvert et que tu veuilles ouvrir un répertoire 'D:\Test\Autres'... et bien le répertoire ne s'ouvrira pas, le code corrigé de Korgis que j'ai fourni donne le nom complet comme sous XP et donc s'ouvrira normalement.
@+
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 07:47
ok, merci de l'info. je n'y avais pas pense.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 08:39
en modifiant cette partie de ton code :

      
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;

par


if Pos(SearchDir, CutAdress) > 0 then
begin
FoundDir := ShowWindow(ExplorerHandle, SW_RESTORE);
BringWindowToTop(ExplorerHandle);
end;


on s'affranchit de savoir si on a affaire a une version française de Windows, non ?
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 09:26
en cherchant un peu plus, je me suis aperçu qu'avec un répertoire 'Autres' ouvert dans le répertoire 'd:\Autres' cad 'd:\Autres\Autres' le repertoire 'd:\Autres' n'etait pas ouvert :
mais avec :

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;

ça fonctionne (les memo1, 2 et 3 sont la pour voir ce qui se passe et sont a enlever après)

dites moi s'il faut optimiser encore ou si on a pris en compte toutes les possibilités ?

--
0
cs_yanb Messages postés 271 Date d'inscription lundi 27 octobre 2003 Statut Membre Dernière intervention 7 juillet 2022 14
Modifié par cs_yanb le 25/02/2014 à 09:45
Salut,
on va dire que le mieux avec les différentes versions XP, W7, Fr, Ang, \:, etc...ce serait probablement ceci :
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;
@+
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 09:49
ok, merci
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 09:51
Pour ceux que ça intéresse : voici le projet final (une form et un bouton)



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.


--
0
drexl Messages postés 56 Date d'inscription mardi 13 février 2007 Statut Membre Dernière intervention 22 juillet 2014
25 févr. 2014 à 09:52
Merci a korgis et a cs_yanb
0
korgis Messages postés 420 Date d'inscription samedi 17 mai 2003 Statut Membre Dernière intervention 6 mai 2019 17
25 févr. 2014 à 11:53
Good job, guys ! ;-)
0
Rejoignez-nous