Process32First

Process32First

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 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

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?

Jugoslav
www.xeffort.com

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.

Steve - Intel Developer Support

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.

Jugoslav
www.xeffort.com

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).)

Allegati: 

AllegatoDimensione
Download toolhelp.zip1.86 KB
Steve - Intel Developer Support

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.

Jugoslav
www.xeffort.com

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!!

Steve,

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

www.quickthreadprogramming.com

Jim,

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.

Steve - Intel Developer Support

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi