How to dllimport in Microsoft Visual C++

后端 未结 3 1507
猫巷女王i
猫巷女王i 2020-12-18 04:44

I have a DLL and I would like to use some of its functions.

#include 

using namespace std;

extern \"C\" __declspec(dllimport) int Initializ         


        
3条回答
  •  时光说笑
    2020-12-18 05:19

    A good way would be to reconstruct some header that would declare the functions you want to call. For doing this, you must know/discover their exact signatures.

    If you have access to the strings command (available in cygwin), you might run it against the DLL. It will list the sequences of more than 4 consecutive printable characters terminated by a 0 (observe that it is really easy to implement, in the case where you do not want to install cygwin). Among these "strings", you will have garbage and the function signatures, mangled by the C++ compiler (see: http://en.wikipedia.org/wiki/Name_mangling). You will then have to unmangle the ones you are interested in, using undname.exe (assuming the DLL was built by Microsoft Visual; see: http://msdn.microsoft.com/en-us/library/5x49w699.aspx)

    ... You might also want to consider DependencyWalker.

提交回复
热议问题