Click here to Skip to main content
13,550,825 members

ATL / WTL / STL

 
GeneralRe: How to Disable open drop down Pin
yaswanthdasari25-Oct-17 23:50
memberyaswanthdasari25-Oct-17 23:50 
QuestionHow To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 21:50
memberMember 1347149317-Oct-17 21:50 
QuestionRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 21:58
protectorRichard MacCutchan17-Oct-17 21:58 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 22:09
memberMember 1347149317-Oct-17 22:09 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 22:12
protectorRichard MacCutchan17-Oct-17 22:12 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149317-Oct-17 22:29
memberMember 1347149317-Oct-17 22:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan17-Oct-17 22:45
protectorRichard MacCutchan17-Oct-17 22:45 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 22:44
mvpJochen Arndt17-Oct-17 22: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 1347149317-Oct-17 23:13
memberMember 1347149317-Oct-17 23:13 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt17-Oct-17 23:29
mvpJochen Arndt17-Oct-17 23:29 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 0:16
protectorRichard MacCutchan18-Oct-17 0:16 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Member 1347149318-Oct-17 0:58
memberMember 1347149318-Oct-17 0:58 
QuestionRe: How To Add a Dll TO MFC Application in visual Studio Pin
Richard MacCutchan18-Oct-17 1:18
protectorRichard MacCutchan18-Oct-17 1:18 
GeneralRe: How To Add a Dll TO MFC Application in visual Studio Pin
Jochen Arndt18-Oct-17 1:40
mvpJochen Arndt18-Oct-17 1:40 
AnswerRe: How To Add a Dll TO MFC Application in visual Studio Pin
Michael Haephrati22-Oct-17 2:22
professionalMichael Haephrati22-Oct-17 2:22 
Questionusing /clr switch for ATL application raises an exception when the application is terminating. Pin
Vijjuuu.23-Aug-17 0:00
memberVijjuuu.23-Aug-17 0:00 
QuestionGetUsbDrive letter error Pin
Member 101933363-Aug-17 0:27
memberMember 101933363-Aug-17 0:27 
QuestionRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 1:18
protectorRichard MacCutchan3-Aug-17 1:18 
AnswerRe: GetUsbDrive letter error Pin
Member 101933363-Aug-17 2:26
memberMember 101933363-Aug-17 2:26 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 2:28
protectorRichard MacCutchan3-Aug-17 2:28 
GeneralRe: GetUsbDrive letter error Pin
Member 101933363-Aug-17 2:36
memberMember 101933363-Aug-17 2:36 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 2:37
protectorRichard MacCutchan3-Aug-17 2:37 
GeneralRe: GetUsbDrive letter error Pin
Richard MacCutchan3-Aug-17 2:32
protectorRichard MacCutchan3-Aug-17 2:32 
QuestionUse ATL COM DLL in VB Script which written in C++ Pin
GTAVLover11-Jul-17 15:03
memberGTAVLover11-Jul-17 15:03 
AnswerRe: Use ATL COM DLL in VB Script which written in C++ Pin
Richard MacCutchan11-Jul-17 21:35
protectorRichard MacCutchan11-Jul-17 21: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 |
Web03 | 2.8.180515.1 | Last Updated 20 Apr 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid