How do I use a third-party DLL file in Visual Studio C++?

前端 未结 6 1487
北恋
北恋 2020-11-28 02:01

I understand that I need to use LoadLibrary(). But what other steps do I need to take in order to use a third-party DLL file?

I simply jumped into C++ and this is th

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 02:35

    You only need to use LoadLibrary if you want to late bind and only resolve the imported functions at runtime. The easiest way to use a third party dll is to link against a .lib.


    In reply to your edit:

    Yes, the third party API should consist of a dll and/or a lib that contain the implementation and header files that declares the required types. You need to know the type definitions whichever method you use - for LoadLibrary you'll need to define function pointers, so you could just as easily write your own header file instead. Basically, you only need to use LoadLibrary if you want late binding. One valid reason for this would be if you aren't sure if the dll will be available on the target PC.

提交回复
热议问题