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

C / C++ / MFC

 
AnswerRe: Creating WMF files? Pin
Braulio Dez9-Apr-02 0:34
Braulio Dez9-Apr-02 0:34 
GeneralVirtual Serial Com Port Pin
GPShady8-Apr-02 23:29
GPShady8-Apr-02 23:29 
GeneralTypedef and more Pin
NicholasCougar8-Apr-02 23:13
NicholasCougar8-Apr-02 23:13 
GeneralRe: Typedef and more Pin
Christian Graus8-Apr-02 23:19
protectorChristian Graus8-Apr-02 23:19 
GeneralRe: Typedef and more Pin
Rickard Andersson208-Apr-02 23:22
Rickard Andersson208-Apr-02 23:22 
GeneralRe: Typedef and more Pin
Christian Graus8-Apr-02 23:25
protectorChristian Graus8-Apr-02 23:25 
GeneralRe: Typedef and more Pin
Rickard Andersson208-Apr-02 23:28
Rickard Andersson208-Apr-02 23:28 
GeneralRe: Typedef and more Pin
Roger Allen9-Apr-02 1:12
Roger Allen9-Apr-02 1:12 
I have used this kind of typedef in the past. Usually when I have loaded a DLL dynamically, and you nned to store function pointers to the return calls from GetProcAddress. This allows you to save the pointers in member vars and call them like function of a regular class once the pointers are correctly initialised.

For example:

typedef int		(*DLLINIT)(int x);
typedef void		(*DLLEXIT)() ;

class DLLWrapper
{
	DLLINIT				DLLInit;
	DLLEXIT				DLLExit ;
	HINSTANCE			hInstance ;

	DLLWrapper(CString& filename)
		{
		DLLInit = NULL ;
		DLLExit = NULL ;
		hInstance = NULL ;
		LoadDll(filename) ;
		} ;
	~DLLWrapper()
		{
		if (hInstance)
			FreeLibrary(hIstance) ;
		hInsatnce = NULL ;
		}

	bool		LoadDLL(CString& filename)
	{
	hInstance = LoadLibrary(filename);
	if (!hInstance)
		return false ;

	DLLInit = (DLLINIT)GetProcAddress(RefinementDLL.pDLL, "DLLInit");
	DLLExit = (DLLEXIT)GetProcAddress(RefinementDLL.pDLL, "DLLExit");
	return true ;
	}
} ;


// you can use the object like this
DLLWrapper	fred("Some.DLL") ;

fred.DLLInit(1) ;		// call through typedef pointer


That lot was put together quickly, so it may not all be 100% correct.



Roger Allen
Sonork 100.10016

If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
GeneralRe: Typedef and more Pin
Rickard Andersson208-Apr-02 23:20
Rickard Andersson208-Apr-02 23:20 
GeneralRe: Typedef and more Pin
Lakitu8-Apr-02 23:24
Lakitu8-Apr-02 23:24 
GeneralRe: Typedef and more Pin
NicholasCougar9-Apr-02 16:19
NicholasCougar9-Apr-02 16:19 
GeneralCRYSTL32.OCX problem ! Pin
Hadi Rezaee8-Apr-02 23:04
Hadi Rezaee8-Apr-02 23:04 
GeneralRe: CRYSTL32.OCX problem ! Pin
l a u r e n9-Apr-02 0:56
l a u r e n9-Apr-02 0:56 
GeneralRe: CRYSTL32.OCX problem ! Pin
Hadi Rezaee9-Apr-02 4:00
Hadi Rezaee9-Apr-02 4:00 
GeneralRe: CRYSTL32.OCX problem ! Pin
Hadi Rezaee9-Apr-02 10:02
Hadi Rezaee9-Apr-02 10:02 
GeneralWord Automation - Extra Info on Tables.. Pin
Braulio Dez8-Apr-02 22:41
Braulio Dez8-Apr-02 22:41 
GeneralSTL and heap management Pin
Haakon S.8-Apr-02 22:26
Haakon S.8-Apr-02 22:26 
GeneralRe: STL and heap management Pin
Christian Graus8-Apr-02 23:21
protectorChristian Graus8-Apr-02 23:21 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 0:20
Haakon S.9-Apr-02 0:20 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 1:07
Joao Vaz9-Apr-02 1:07 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 1:50
Haakon S.9-Apr-02 1:50 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 3:48
Joao Vaz9-Apr-02 3:48 
GeneralRe: STL and heap management Pin
Tim Smith9-Apr-02 4:10
Tim Smith9-Apr-02 4:10 
GeneralRe: STL and heap management Pin
Joao Vaz9-Apr-02 4:49
Joao Vaz9-Apr-02 4:49 
GeneralRe: STL and heap management Pin
Haakon S.9-Apr-02 8:17
Haakon S.9-Apr-02 8:17 

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.