Windows PSAPI - 3 files [1/1]
sleek
cslush at gmail.com
Sun Sep 7 12:15:19 PDT 2008
Another great tip. Thanks, I'll look into this one next time I need to
create a custom lib file.
"wyverex" <wyverex.cypher at gmail.com> wrote in message
news:ga18jq$1h5m$1 at digitalmars.com...
> Sergey Gromov wrote:
>> 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.
>
>
> Always try using linkdef
> http://www.dprogramming.com/linkdef.php
More information about the Digitalmars-d-learn
mailing list