How can i use Process32First in VF program. My linker doesn't recognize it.
I have added the Use DFWIN statement at the beginning.

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The appropriate C header Thelp32.h apparently wasn't translated to Fortran in VF. See this discussion, which uses Psapi functions for a similar task (I think that Steve has a full translation of Psapi.h somewhere).

You can also do the translation of necessary interfaces, types and constants from Thelp32.h yourself -- it's a bit tedious task though (on a brigher side, it is in Kernel32.lib so you don't have to do the dynamic binding)... Actually, Steve, why are so many APIs missing from the VF Windows headers?


Why? Because we haven't found the time to figure out what changed and do the additions. Actuall, we did some work for the upcoming 10.0 in this regard but in no way is it comprehensive. We'll keep at it. It helps if you let us know what's missing that you want to use.

10.0 will include PSAPI.

Retired 12/31/2016

I want to use CreateToolhelp32Snapshot, Process32First / Next and the structure PROCESSENTRY32.
Actually I need to terminate a process by name. I don't know if this can be done in other way using VF.

Thanks a lot for the answers!!

See the link I previously gave -- the relevant thread is titled "Win API", I can't manage to link it directly. It provides a sample code for enumerating processes and their modules using PSAPI -- you can easily adapt it.


ok, thanks!!

I've tried the code in your page, but i have another question.

When i try to terminate a process using terminateprocess i get an error '5' which means "access is denied". I dont know if i'm missin something

I've attached a TOOLHELP module that defines the Tool Help items. Let me know how it works for you. Requires a recent version of Intel Visual Fortran (supporting IMPORT and BIND(C).)


Downloadapplication/zip toolhelp.zip1.86 KB
Retired 12/31/2016

Heh, yes . As a well-designed (cough) operating system, Windows doesn't provide a "license to kill" to ordinary user-mode processes. Normally, a process may kill its children, but I don't know if killing other processes is allowable. Let me try...

...It seems that it's possible, though, at least for other user-mode processes -- you just have to add PROCESS_TERMINATE flag to the flags of OpenProcess.


Thanks a lot!!

I have an old version of Visual Fortran (Compaq Visual Fortran 6.6). But i think i'm goint to get the newest version of Intel VF soon.

Any way, the code in xeffort was perfect for my needs.

Thanks again!!


Wouldn't it be useful for some Jr. software engineer to be tasked with writing a C/C++ header file to IVF interface conversion tool? Automation would seem like the way to go.

Jim Dempsey


We actually used some automation back in CVF 6.1. But it only gets you part way there, and there is a LOT of manual cleanup needed, with some intelligence required when the C declaration is a pointer, and the C headers don't have INTENT.

What we probably will do is use automation to at least let us know what we're missing, but it's actually faster, believe it or not, for someone (like me) to just sit down and hand-translate a bunch of definitions.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today