Windows PSAPI - 3 files [1/1]

Sergey Gromov snake.scaly at gmail.com
Sun Sep 7 11:50:17 PDT 2008


sleek <cslush at gmail.com> wrote:
> Sergey,
> 
> Thanks for the response. Lucky for me, I actually fixed those first couple 
> bugs you mentioned after looking at the code a bit more. Unluckily for me, 
> it still sounds like I'm somewhat screwed. Does anyone else out there have 
> any info as to how I can use PSAPI from D?

See attached.  These are the correct import library and fixed bindings.

It wasn't easy to create the library though.  First I've got Psapi.h 
from Microsoft Platform SDK and modified it as suggested in this 
article:

    http://support.microsoft.com/kb/131313

Then I went the hard way which is of no interest.  The right way is to 
compile the header into an obj file and then dump its symbols.  The 
compiler to use depends on what tools you've got handy.  I've got the 
complete Microsoft SDK so I used

    cl -c psapi.c
    dumpbin /symbols psapi.obj >psapi.def

Remove everything except the names, add 'LIBRARY "psapi.dll"' and 
'EXPORTS' at the top, and you're almost done with the .def file. 
"Almost" because functions in actual DLL are not mangled, so you need to 
specify an internal name.  Use any regular expression tool to convert 
"_Anything at digits" into "_Anything at digits = Anything".  That's it.  Now 
use

    implib psapi psapi.def

to produce the correct import library.

I wonder if there is an easier way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 5120 bytes
Desc: PSAPI import library
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20080907/5c4dd574/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 5985 bytes
Desc: PSAPI bindings
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20080907/5c4dd574/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 1780 bytes
Desc: Definition file for psapi.dll
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20080907/5c4dd574/attachment-0005.obj>


More information about the Digitalmars-d-learn mailing list