Click here to Skip to main content
15,112,354 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: How to Disable open drop down Pin
yaswanthdasari26-Oct-17 0:50
Memberyaswanthdasari26-Oct-17 0:50 
QuestionHow To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 22:50
MemberMember 1347149317-Oct-17 22:50 
QuestionRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 22:58
mveRichard MacCutchan17-Oct-17 22:58 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 23:09
MemberMember 1347149317-Oct-17 23:09 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 23:12
mveRichard MacCutchan17-Oct-17 23:12 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 23:29
MemberMember 1347149317-Oct-17 23:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 23:45
mveRichard MacCutchan17-Oct-17 23:45 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 23:44
professionalJochen Arndt17-Oct-17 23:44 
To use functions from a DLL you have two choices: Early and late binding.

Early binding:
Link your application with the DLL by using the #import directive in one file (usually a source file using functions from the DLL) specifying the file name (usually without extension or with .lib), or add the .lib file to your project settings (Linker - Input).
Include the header file and call the functions defined in that file.

Late binding:
This is only necessary if the DLL might not be present when your application is executed or you do not have a .lib file. Then use LoadLibrary and GetProcAddress like in your above example. But check both return values to be not NULL. Have a look at the header file (if present), to know how to define the function prototypes. Example:
C++
typedef int (__stdcall *ConnectByAddressfuncPtr)(short Addr); 

ConnectByAddressfuncPtr LibMainConnectByAddress = NULL;
HMODULE hLib = LoadLibrary(_T("mcl_gen.dll"));
if (hLib)
    LibMainConnectByAddress = (ConnectByAddressfuncPtr)GetProcAddress(hLib,"ConnectByAddress");
if (LibMainConnectByAddress)
    LibMainConnectByAddress(0x01);
Note that I have initialised the function pointer with NULL and checked it before calling the function. Note also the __stdcall in the prototype declaration. It defines the calling convention used by the DLL. You have to check which is used (by inspecting the header file or asking the provider). __stdcall is common but it might be also __cdecl.
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149318-Oct-17 0:13
MemberMember 1347149318-Oct-17 0:13 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt18-Oct-17 0:29
professionalJochen Arndt18-Oct-17 0:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 1:16
mveRichard MacCutchan18-Oct-17 1:16 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149318-Oct-17 1:58
MemberMember 1347149318-Oct-17 1:58 
QuestionRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 2:18
mveRichard MacCutchan18-Oct-17 2:18 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt18-Oct-17 2:40
professionalJochen Arndt18-Oct-17 2:40 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Michael Haephrati22-Oct-17 3:22
professionalMichael Haephrati22-Oct-17 3:22 
Questionusing /clr switch for ATL application raises an exception when the application is terminating. Pin
Vijjuuu.23-Aug-17 1:00
MemberVijjuuu.23-Aug-17 1:00 
QuestionGetUsbDrive letter error Pin
Member 101933363-Aug-17 1:27
MemberMember 101933363-Aug-17 1:27 
QuestionRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 2:18
mveRichard MacCutchan3-Aug-17 2:18 
AnswerRe: GetUsbDrive letter error Pin
Member 101933363-Aug-17 3:26
MemberMember 101933363-Aug-17 3:26 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 3:28
mveRichard MacCutchan3-Aug-17 3:28 
GeneralRe: GetUsbDrive letter error Pin
Member 101933363-Aug-17 3:36
MemberMember 101933363-Aug-17 3:36 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 3:37
mveRichard MacCutchan3-Aug-17 3:37 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 3:32
mveRichard MacCutchan3-Aug-17 3:32 
QuestionUse ATL COM DLL in VB Script which written in C++ Pin
GTAVLover11-Jul-17 16:03
MemberGTAVLover11-Jul-17 16:03 
AnswerRe: Use ATL COM DLL in VB Script which written in C++ Pin
Richard MacCutchan11-Jul-17 22:35
mveRichard MacCutchan11-Jul-17 22:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.