-1

If I want to import a C++ class from a DLL, which API should I use after LoadLibrary() returns?

I was searching in the following link, but I just found the GetProcAddress() and it seems like it will not work for a class. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682599%28v=vs.85%29.aspx

Niall
  • 30,036
  • 10
  • 99
  • 142
XIJINPING
  • 1
  • 3
  • "import" is not a C++ concept (unless you mean the Microsoft-specific #import which is a compile-time operation (no LoadLibrary() needed.). Are you trying to 1) create an instance of a class that is declared and defined in a DLL, or 2) use a class returned by a method in a DLL or 3)derive your own class from a base class declared/defined in a DLL, or [something else].... – Dale Wilson Jul 02 '14 at 20:49
  • “import” may not suitable ,I just want use a c++ class which in a DLL,I need a function to get it – XIJINPING Jul 02 '14 at 20:56
  • Why are you calling LoadLibrary()? – Dale Wilson Jul 02 '14 at 20:58
  • i call it Because i need dll loaded into memory ,sorryI may not explain that clearly, my question is how to use a c++class in my program ,and the class is in a dll,and how should i write after LoadLibrary()? – XIJINPING Jul 02 '14 at 21:18
  • Please see the linked question (over there ---> ) about __declspec and see if this answers your question. If so, consider closing this question as a duplicate. – Dale Wilson Jul 02 '14 at 21:40

1 Answers1

1

You cannot import a class using LoadLibrary.

You need to use a header file and an import library and link at compile time. The header file will use __declspec(dllimport) to import the class.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490