I lang tid har samarbejdsbranchen fokuseret på at forbedre enhedsfunktioner – bedre kameraer, klarere lyd og smartere software. Men den virkelige forvandling handler ikke om funktioner.
Type TEnumData = Record hW: HWND; pID: DWORD; End;
Function EnumProc( hw: HWND; Var data: TEnumData ): Bool; stdcall; Var pID: DWORD; Begin Result := True; If (GetWindowLong(hw, GWL_HWNDPARENT) = 0) and (IsWindowVisible( hw ) or IsIconic(hw)) Then Begin GetWindowThreadProcessID( hw, @pID ); If pID = data.pID Then Begin data.hW := hW; Result := False; End; { If } End; { If } End; { EnumProc }
Function WindowFromProcessID( pID: DWORD ): HWND; Var data: TEnumData; Begin data.pID := pID; data.hW := 0; EnumWindows( @EnumProc, longint(@data) ); Result := data.hW; End; { WindowFromProcessID }
Function WindowFromAppname32( appname: String ): HWND; { Take only the application filename, not full path! Need to pass the extension as well. } Var snapshot: THandle; processEntry : TProcessEntry32; Begin Result := 0; snapshot := CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); If snapshot <> 0 Then try processEntry.dwSize := Sizeof( processEntry ); If Process32First( snapshot, processEntry ) Then Repeat If AnsiCompareText( appname, ExtractFilename( StrPas(processEntry.szExeFile)) ) = 0 Then Begin Result:= WindowFromProcessID( processEntry.th32ProcessID); Break; End; { If } Until not Process32Next( snapshot, processEntry ); finally CloseHandle( snapshot ); End; { try } End; { WindowFromAppname32 }
procedure TForm1.Button1Click(Sender: TObject); begin if WindowFromAppname32('msnmsgr.exe') <> 0 then ShowMessage('Messenger kører') else ShowMessage('Messenger kører ikke'); end;
Darkside > LUR mener du ikke lue (fra email fra lønneberg)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.