Skip to main content

 none
Static Linking to IMAPI2 RRS feed

  • Question

  • I am using VS 2015 and C++.  Is it possible to statically link to IMAPI2?  I don't see any *.lib files for IMAPI2...

    Regards,

    Scott

    Monday, July 24, 2017 8:56 PM

All replies

  • IMAPI are interfaces, so you just have to add :

    #include <imapi2.h>

    then you can do things like :

    HRESULT hr = E_UNEXPECTED;
    IDiscMaster2* pDiscMaster2 = NULL;
    hr = CoCreateInstance(CLSID_MsftDiscMaster2, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pDiscMaster2));
    if (SUCCEEDED(hr))
    { 
    	LONG nCount;
    	hr = pDiscMaster2->get_Count(&nCount);
    	// etc...
    }


    • Edited by Castorix31 Monday, July 24, 2017 9:39 PM
    Monday, July 24, 2017 9:38 PM
  • Castorix31,

    Thank you for your quick reply.  I know that IMAPI2 is a set of COM interfaces.  I use them all the time.  :)

    However, my DLL or EXE will always dynamically link to imapi2.dll.  That also means IMAPI2 will fail if imapi2.dll is missing.  My question is how do I statically link to IMAPI2?   With static linking, the code (IMAPI2 in this case) becomes a permanent part of my DLL or EXE at link time.  This eliminates the dependency on the DLL.  Usually, this is achieved by including one or more library (*.lib) files at link time.  Unfortunately, I cannot locate any such library files for IMAPI2.

    Regards,

    Scott

     

    Monday, July 24, 2017 9:54 PM
  • you can't. It is an API, not a library. When the 2.0 library is missing you either downgrade to 1.0 or instruct the user to upgrade Windows. 




    Visual C++ MVP

    Tuesday, July 25, 2017 4:55 AM