Posted December 9, 200717 yr hi friendsPlease help me for get ProcessID From File name i have a process . this process hase not caption and i must get this process id .!!sorry for my Poor English!!
December 9, 200717 yr Are you talking programmatically or not?, CreateToolhelp32Snapshot and associated functions Process32First/Process32Next is one way if not any process viewer will display it. Edited December 9, 200717 yr by zako
December 10, 200717 yr here is working examplehttp://www.delphipages.com/threads/thread.cfm?ID=184341&G=184250This get the handel of the process but it first gets its process ID from the exe file name, So after reading this you should'nt have any problems
December 10, 200717 yr See if this function does it for you...Function EnumThreadProc( wnd: HWND; Var appHwnd: HWND ): LongBool; stdcall;Var buf: array [0..128] of Char;Begin Result := LongBool(1); if GetClassname( wnd, buf, sizeof(buf)) > 0 then If StrComp( buf, 'TApplication' ) = 0 Then Begin appHwnd := Wnd; Result := False; End; { If }End;Function FindApplicationWindow( forThreadID: DWORD ): HWND;Begin Result := 0; EnumThreadWindows( forThreadID, @EnumThreadProc, lparam(@result));End;Function ProcessIDFromAppname32( appname: String ): DWORD; { Take only the application filename, not full path! } Var snapshot: THandle; processEntry : TProcessEntry32; Begin Result := 0; appName := UpperCase( appname ); snapshot := CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); If snapshot <> 0 Then try processEntry.dwSize := Sizeof( processEntry ); If Process32First( snapshot, processEntry ) Then Repeat If Pos(appname, UpperCase(ExtractFilename( StrPas(processEntry.szExeFile)))) > 0 Then Begin Result:= processEntry.th32ProcessID; Break; End; { If } Until not Process32Next( snapshot, processEntry ); finally CloseHandle( snapshot ); End; { try } End; Edited December 10, 200717 yr by ante0
Create an account or sign in to comment