V65j Posted December 9, 2007 Share Posted December 9, 2007 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!! Link to comment
zako Posted December 9, 2007 Share Posted December 9, 2007 (edited) 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, 2007 by zako Link to comment
V65j Posted December 10, 2007 Author Share Posted December 10, 2007 can you write an example code? Link to comment
ChupaChu Posted December 10, 2007 Share Posted December 10, 2007 search for JCL delphi package, its simple then. Link to comment
Departure Posted December 10, 2007 Share Posted December 10, 2007 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 Link to comment
ante0 Posted December 10, 2007 Share Posted December 10, 2007 (edited) 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, 2007 by ante0 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now