Click here to Skip to main content
13,768,886 members

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
protectorRichard 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
protectorRichard 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
protectorRichard MacCutchan17-Oct-17 23:45 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 23:44
mvpJochen 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:
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
mvpJochen Arndt18-Oct-17 0:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 1:16
protectorRichard 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
protectorRichard MacCutchan18-Oct-17 2:18 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt18-Oct-17 2:40
mvpJochen Arndt18-Oct-17 2:40 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Michael Haephrati22-Oct-17 3:22
mvpMichael 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
protectorRichard 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
protectorRichard 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
protectorRichard MacCutchan3-Aug-17 3:37 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 3:32
protectorRichard 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
protectorRichard 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.


Advertise | Privacy | Cookies | Terms of Service
Web06-2016 | 2.8.181117.1 | Last Updated 16 Oct 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid