Linking in advapi32.lib and netlib32.lib
Don Clugston
dac at nospam.com.au
Thu Apr 20 09:30:47 PDT 2006
Daniel Keep wrote:
> Sorry for the tardy reply... been busy.
>
> John C wrote:
>> Daniel Keep wrote:
>>> # extern(Windows)
>>> # int
>>> # GetUserNameW(
>>> # wchar* lpBuffer,
>>> # uint* nSize
>>> # )
>>>
>>> I'm using XP, so I'm fairly sure GetUserNameW should be there (well,
>>> it's there in advapi32.dll -- dependency walker says so).
>> Yes, GetUserNameW is from advapi32. The error message you're getting
>> usually means Windows can't find the DLL.
>>
>> What error code do you get if you call LoadLibrary("advapi32.dll")? If
>> it returns 0, then there's something else wrong. Is the original lib
>> file from the Platform SDK? Or did you get it by other means? I think
>> coffimplib only works on the Microsoft lib files.
>
> The original .LIB files are from the MS Platform SDK installed with
> Visual Studio .NET 2003. Ran them through using "coffimplib IN.lib
> OUT.lib".
>
> As for LoadLibrary, now I can't get THAT to link properly (sob). MSDN
> says that it's in Kernel32.lib, but it still can't resolve it if I link
> that in.
You will need to link to LoadLibraryA() or LoadLibraryW(). There's no
function called LoadLibrary(), it's an alias.
(Unless you use winbase from the win32 bindings library, which aliases
them to LoadLibrary for you -- although note that the win32 bindings are
in an alpha state, and not very well tested).
> Honestly, I have better things to do with my time than fight with dmd
> over this. I think I'll just wait until the win32 bindings cover what I
> need, and then try again.
>
> Many thanks for your help.
>
>>> John C wrote:
>>>
>>>> Daniel Keep wrote:
>>>>
>>>>> <sigh> Oh never mind. This code just *doesn't* want to work... Every
>>>>> time I try to call a function in advapi32, it returns the Win32 error
>>>>> code for "A dynamic link library (DLL) initialization routine failed.".
>>>>>
>>>>> And then, even if I hardcode the user name to my own current user name,
>>>>> it refuses to let me see my own home directory :(
>>>>>
>>>>> Stupid Windows...
>>>> What's the function you're trying to call? And what does your function
>>>> definition look like?
>>>>
>>>> I just tried GetUserName and it worked.
>>>>
>>>>
>>>>> Thanks for the help anyway, John. Think I'll play with embedding
>>>>> Python
>>>>> for a while instead. So far I've got it in a simple read-eval loop :P
>>>>>
>>>>> -- Daniel "hates win32"
>>>
>
More information about the Digitalmars-d
mailing list