Accessing CoInit [is Troubleshooting Linker error]

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Oct 2 02:48:00 PDT 2012


On 10/2/12, Jesse Phillips <jessekphillips+D at gmail.com> wrote:
> I've made the changes needed to get past the linker error

I'm sorry, I was completely wrong about STDAPI being extern(C). I saw
EXTERN_C and immediately thought this was the calling convention, it's
not:

#define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
#define STDAPICALLTYPE          __stdcall

So this is actually extern(Windows).

Linker errors persist when using implib, but when using coffimplib on
an existing COFF import library it will link and work at runtime.

Here's one I made just now: https://dl.dropbox.com/u/9218759/Ole32_dmd.lib
It works for me with this:

pragma(lib, "Ole32_dmd.lib");

extern(Windows)
int CoInitializeEx(void*, uint dwCoInit);

void main()
{
     CoInitializeEx(null, 0x2);
}


More information about the Digitalmars-d-learn mailing list