Click here to Skip to main content
16,005,038 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: format of Windows .TXT files Pin
David Crow2-Jan-08 8:39
David Crow2-Jan-08 8:39 
GeneralRe: format of Windows .TXT files Pin
CPallini2-Jan-08 9:57
mveCPallini2-Jan-08 9:57 
GeneralA project made from XPCOM components and VC++6.0 (I desperately need for any ideas) Pin
cuesdean florin2-Jan-08 5:44
cuesdean florin2-Jan-08 5:44 
GeneralRe: A project made from XPCOM components and VC++6.0 (I desperately need for any ideas) Pin
led mike2-Jan-08 8:19
led mike2-Jan-08 8:19 
GeneralHelp on DLL export Pin
tiwal2-Jan-08 5:19
tiwal2-Jan-08 5:19 
GeneralRe: Help on DLL export Pin
CPallini2-Jan-08 5:36
mveCPallini2-Jan-08 5:36 
GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 21:58
tiwal2-Jan-08 21:58 
GeneralRe: Help on DLL export Pin
CPallini2-Jan-08 22:29
mveCPallini2-Jan-08 22:29 
tiwal wrote:
Here , I am using .cpp files in both the dll and the calling program, so there shouldn't be any of these problems

This is wrong, because GetProcAddress does not expect a C++ mangled function.

I made a little test:
DLL header
...
#ifdef DLLTEST_EXPORTS
#define DLLTEST_API __declspec(dllexport)
#else
#define DLLTEST_API __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"
{
#endif
  DLLTEST_API int fnDLLMul(int i, int j);
#ifdef __cplusplus
};
#endif


DLL source code
...
DLLTEST_API int fnDLLMul(int i, int j)
{
  return i*j;
}


Client source code
#include "stdafx.h"
#include <windows.h>

typedef int (*LPFUNMUL)(int, int);

int _tmain(int argc, _TCHAR* argv[])
{
  int i=5;
  int j=6;

  HMODULE hLib = LoadLibrary(_T("..\\..\\DLLTest\\debug\\DllTest.Dll"));
  LPFUNMUL fnMul =(LPFUNMUL) GetProcAddress(hLib, "fnDLLMul");
  DWORD dwErr= GetLastError();

  _tprintf(_T("%d * %d = %d"), i, j, fnMul(i,j));
  getchar();
}



And it works fine (error checking left to the reader).

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 23:49
tiwal2-Jan-08 23:49 
GeneralRe: Help on DLL export Pin
CPallini3-Jan-08 0:04
mveCPallini3-Jan-08 0:04 
GeneralRe: Help on DLL export Pin
tiwal3-Jan-08 21:31
tiwal3-Jan-08 21:31 
GeneralRe: Help on DLL export Pin
CPallini3-Jan-08 21:49
mveCPallini3-Jan-08 21:49 
GeneralRe: Help on DLL export Pin
led mike2-Jan-08 5:36
led mike2-Jan-08 5:36 
GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 22:00
tiwal2-Jan-08 22:00 
GeneralRe: Help on DLL export Pin
Matthew Faithfull2-Jan-08 5:43
Matthew Faithfull2-Jan-08 5:43 
GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 22:13
tiwal2-Jan-08 22:13 
GeneralRe: Help on DLL export Pin
CPallini2-Jan-08 22:33
mveCPallini2-Jan-08 22:33 
QuestionRe: Help on DLL export Pin
David Crow2-Jan-08 8:45
David Crow2-Jan-08 8:45 
GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 22:19
tiwal2-Jan-08 22:19 
QuestionRe: Help on DLL export Pin
David Crow3-Jan-08 6:53
David Crow3-Jan-08 6:53 
GeneralRe: Help on DLL export Pin
tiwal3-Jan-08 21:49
tiwal3-Jan-08 21:49 
GeneralHi David Pin
Hamid_RT3-Jan-08 6:09
Hamid_RT3-Jan-08 6:09 
GeneralRe: Hi David Pin
David Crow3-Jan-08 6:45
David Crow3-Jan-08 6:45 
GeneralRe: Help on DLL export Pin
Hamid_RT2-Jan-08 18:16
Hamid_RT2-Jan-08 18:16 
GeneralRe: Help on DLL export Pin
tiwal2-Jan-08 22:21
tiwal2-Jan-08 22:21 

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.