Accessing CoInit [is Troubleshooting Linker error]

Jesse Phillips jessekphillips+D at gmail.com
Tue Oct 2 07:15:20 PDT 2012


On Tuesday, 2 October 2012 at 09:48:00 UTC, Andrej Mitrovic wrote:
> 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);
> }

Thank you, it does work, and I figured out why my coffimplib 
didn't work. I forgot to rename it, so I moved it as out.lib :( 
I'm going to go write up some docs tonight.


More information about the Digitalmars-d-learn mailing list