🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #2866

Re: Dynamic Run-Time import with C++

#2866
From: CADSI
Date: Mon, 27 May 1991 18:38
31 lines
1740 bytes
From article <1991May27.123911.3813@waikato.ac.nz>, by iam@waikato.ac.nz (Ian McDonald):
> I'm trying to call a DLL routine dynamically (ie using a LoadLibrary) but I am
> having difficulty because of C++ type checking.  In C you can go :
> 
>   (*lpFunc) ((LPSTR) Buffer,512);
> 
> for example if lpFunc is of type FARPROC.  (This is taken from page 20-33 of
> the SDK Guide to Programming).  With C++ it will not let me do this because of
> the type checking.  I have tried (and failed) to make a typedef to do this
> although I am not too experienced with typedef.  Could somebody help me out by
> showing me a way to have a typedef equivalent to FARPROC but allows parameters
> (defined in advannce) or do a typecast to use FARPROC properly.

CHEAP Example:

	{
		FARPROC lpfn = (FARPROC)lpFunc;
		(*lpfn)((LPSTR)Buffer, 512);
	}

Otherwise, just typedef the call inline:

	(*((FARPROC)lpFunc))((LPSTR)Buffer, 512);

Both should work.

|----------------------------------------------------------------------------|
|Tom Hite					|  The views expressed by me |
|Manager, Product development			|  are mine, not necessarily |
|CADSI (Computer Aided Design Software Inc.	|  the views of CADSI.       |
|----------------------------------------------------------------------------|
Technical Details
Message-ID: <1991May27.183808.24200@ccad.uiowa.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!ns-mx!ccad.uiowa.edu!cadsi
References: <1991May27.123911.3813@waikato.ac.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!ns-mx!ccad.uiowa.edu!cadsi
From: cadsi@ccad.uiowa.edu (CADSI)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Dynamic Run-Time import with C++
Message-ID: <1991May27.183808.24200@ccad.uiowa.edu>
Date: 27 May 91 18:38:08 GMT
References: <1991May27.123911.3813@waikato.ac.nz>
Organization: CAD-Research, U. of Iowa, Iowa City, Iowa
Lines: 31