- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Is there a way to get the parent process ID in Visual Fortran ?
Or should I have to mix language ?
Or should I have to mix language ?
링크가 복사됨
12 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Um, parent process ID? Windows does not even have concept of parent and child processes -- it's a Unixian thingo. One can spawn a "child" process via CreateProcess, but the relationship between "child" and "parent" is very weak and AFAIK there's no way to reach the "parent" process (unless the "parent" passes that information explicitly, e.g. using command line). What exactly you're trying to do?
Jugoslav
Jugoslav
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
James, I'm affraid you'll have to support that statement with a code sample :-).
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
OK, you win -- I didn't count on undocumented APIs :-).
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
That's correct. However, if you snapshot the system via CreateToolHelp32Snapshot, then the snapshot and GetCurrentProcessID allow you to get the process entry data for the current app and hence the parent process id. This is then passed with the snapshot to Process32First(Next) to reveal the name of the parent process as the last member of the PROCESSENTRY32 struct. This approach is preferable to use of internal functions of ntdll as advised in MSDN. Also, snapshots can reveal details on app modules (including loaded ocx's, dll's, and their versioning info) and the threads spawned by the app, wittingly or otherwise.
Ciao,
Gerry T.
Ciao,
Gerry T.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Gerry, yes, that approach is fine in practice although it would be quite a bit more verbose than my example, which was intended to demonstrate a concept. Note that I also mentioned there were more official interfaces available, but didn't have time to whip up an example based on that approach just to show that it was possible.
Cheers,
James
Cheers,
James
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi James
I found your demo to be highly instructive and I'm sorry if I came across as unappreciative. Snapshotting is more bother and besides it hasn't made into CVF's kernel32 yet.
Have you noticed that if you run it from the ide, the parent is the ide; if you double click the .exe, the parent is Explorer; and if you shell it, the parent is the sheller. Ditto for the snapshot approach. I hope my pc hasn't been invaded by Raelians, :-).
Ciao,
Gerry T.
I found your demo to be highly instructive and I'm sorry if I came across as unappreciative. Snapshotting is more bother and besides it hasn't made into CVF's kernel32 yet.
Have you noticed that if you run it from the ide, the parent is the ide; if you double click the .exe, the parent is Explorer; and if you shell it, the parent is the sheller. Ditto for the snapshot approach. I hope my pc hasn't been invaded by Raelians, :-).
Ciao,
Gerry T.
