var
NTPID:TProcessrecs;
win : HWND;
tempString:
array[0..255]
of Char;
i,j : Integer;
ProcID : DWord;
SSHandle : THandle;
Contin : boolean;
ProcEntry : TProcessEntry32;
temp:
string;
bWinNT:boolean;
begin
Dir := '
';
Version := '
';
bWinNT :=
WinNT;
win := GetTopWindow(0);
tempString := '
';
for i := 0
to 255
do begin
win := GetNextWindow(win,GW_HWNDNEXT);
GetWindowText(win, tempString, 255);
if (Pos('
EXPLORER', Uppercase(tempString)) = 0)
then
continue
else
begin
if GetOSName <> '
Windows NT'
then begin
GetWindowThreadProcessID(FindWindow(
nil,tempstring), @ProcID);
SSHandle := CreateToolhelp32Snapshot(TH32CS_SnapProcess, 0);
ProcEntry.dwSize := Sizeof(ProcEntry);
Contin := Process32First(SSHandle, ProcEntry);
while Contin
do begin
if ProcEntry.th32ProcessID = ProcID
then
begin
Temp := Uppercase(ProcEntry.szExeFile)
else
if (Pos('
EXPLORER',Temp) <>0)
then
if bWinNT
then begin
Dir := '
';
Version := tempstring;
result := ProcEntry.th32ProcessID;
exit;
end else
begin
Dir := Extractfilepath(ProcEntry.szExeFile);
Version := tempstring;
result := ProcEntry.th32ProcessID;