Как получить список запущенных приложений?
В DRKB способ не стабильный....
function EnumWindowsProc(wnd:HWND; lParam: LPARAM):BOOL; stdcall;
var
wn:array[0..MAX_PATH-1] of char;
begin
result:=true;
if IsWindowVisible(wnd) and (GetParent(wnd)=0) and (GetWindow(wnd,GW_OWNER)=0) and
((GetWindowLong(wnd,GWL_EXSTYLE) and WS_EX_TOOLWINDOW)=0) then
begin
GetWindowText(wnd,wn,MAX_PATH);
Form1.Memo1.Lines.Add('"'+string(wn)+'"');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear;
EnumWindows(@EnumWindowsProc,0);
end;
Const
MaxThreadBox = MaxByte * 3;
FreeSlotValue = 0;
Var
TrackingProcessBoxs: Array[1..MaxThreadBox] Of HWND;
Function ExistHWND(iWnd: HWND): Boolean;
Procedure FreeBox(iIndex: Integer);
Function GetFreeBox: Integer;
Function AddUseBox(iWnd: HWND): Integer;
///...
Uses ThreadTrackingProcess_Unit, Main_Form;
Function ExistHWND(iWnd: HWND): Boolean;
Var
VCurrentPosScan: Integer;
Begin
Result := False;
For VCurrentPosScan := 1 To MaxThreadBox Do
Begin
If TrackingProcessBoxs[VCurrentPosScan] = iWnd Then
Begin
Result := True;
Break;
End;
End;
End;
Procedure FreeBox(iIndex: Integer);
Begin
TrackingProcessBoxs[iIndex] := FreeSlotValue;
End;
Function GetFreeBox: Integer;
Var
VCurrentPosScan: Integer;
Begin
Result := FreeSlotValue;
For VCurrentPosScan := 1 To MaxThreadBox Do
Begin
If TrackingProcessBoxs[VCurrentPosScan] = FreeSlotValue Then
Begin
Result := VCurrentPosScan;
Break;
End;
End;
End;
Function AddUseBox(iWnd: HWND): Integer;
Begin
Result := GetFreeBox;
TrackingProcessBoxs[Result] := iWnd;
End;