🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Dynamic Run-Time import with C++

#2905
From: CADSI
Date: Mon, 27 May 1991 23:38
34 lines
1814 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.       |
|----------------------------------------------------------------------------|

 * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)
Technical Details
Message-ID: <675432063.17@sunbrk.FidoNet>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!uunet!zephyr.ens.tek.com!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!uunet!zephyr.ens.tek.com!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet
From: CADSI@sunbrk.FidoNet.Org (CADSI)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Dynamic Run-Time import with C++
Message-ID: <675432063.17@sunbrk.FidoNet>
Date: 27 May 91 23:38:08 GMT
Sender: Usenet@sunbrk.FidoNet.Org
Lines: 34