[comp.windows.ms.programmer] How Do I Call Function After GetProcAddress

rdthomps@vela.acs.oakland.edu (Robert D. Thompson) (06/10/91)

	I seem to be having problems calling a function after
	GetProcAddress()

	Basically,

		lpfnFunction = GetProcAddress(...)

	Then I want to call the function.

	I remember doing something similar a while back, but I 
	can't seem to get this to work...even with

		(lpfnFunction)(<argument list>);

	Any help would be appreciated.

	Thanks
---
Robert

bonneau@hyper.hyper.com (Paul Bonneau) (06/11/91)

In article <6931@vela.acs.oakland.edu>
rdthomps@vela.acs.oakland.edu (Robert D. Thompson) writes:
>
>	I seem to be having problems calling a function after
>	GetProcAddress()
>
>	Basically,
>
>		lpfnFunction = GetProcAddress(...)
>
>	Then I want to call the function.
>
>	I remember doing something similar a while back, but I 
>	can't seem to get this to work...even with
>
>		(lpfnFunction)(<argument list>);
>
>	Any help would be appreciated.
>
You need to use CallWindowProc() with the lpfn as the first
param, followed by the arg list.

cheers - Paul Bonneau.

rdthomps@vela.acs.oakland.edu (Robert D. Thompson) (06/11/91)

EXTDEVICEMODE - HOW TO GET DEVICE INFO - DEVMODE OR A SIMPLE
BUFFER???!!!)
Summary: 
Expires: 
References: <6931@vela.acs.oakland.edu> <1991Jun10.214915.1973@hyper.hyper.com>
Sender: 
Followup-To: 
Distribution: 
Organization: Oakland University, Rochester MI.
Keywords: 

In article <1991Jun10.214915.1973@hyper.hyper.com> bonneau@hyper.hyper.com (Paul Bonneau,,) writes:
>In article <6931@vela.acs.oakland.edu>
>rdthomps@vela.acs.oakland.edu (Robert D. Thompson) writes:
>>
>>	I seem to be having problems calling a function after
>>	GetProcAddress()
>>
>>	Basically,
>>
>>		lpfnFunction = GetProcAddress(...)
>>
>>	Then I want to call the function.
>>
>>	I remember doing something similar a while back, but I 
>>	can't seem to get this to work...even with
>>
>>		(lpfnFunction)(<argument list>);
>>
>>	Any help would be appreciated.
>>
>You need to use CallWindowProc() with the lpfn as the first
>param, followed by the arg list.
>
>cheers - Paul Bonneau.

Paul,

	Actually, the SDK sample application MULTIPAD, specifically
	MPPRINT.C, contains (somewhat) what I am trying to do.

	I am simply trying to get device independent AND device
	dependent settings for a particular device.  To do this,
	I need to call ExtDeviceMode.

	The ExtDeviceMode function is exported my most drivers,
	including printer drivers like PSCRIPT.DRV.

	So, the first thing you need to do is load the driver using
	LoadLibrary();  Then get the procdure address of ExtDeviceMode
	via GetProcAddress();  Finally I need to call ExtDeviceMode
	first with NULL as wMode to get the size of the DEVMODE
	data struction, then a second time to fill the struction.

	MPPRINT.C (a module of MULTIPAD.EXE) does this as follows,

    /* Load the device driver and find the ExtDeviceMode() function */

    wsprintf (sz, "%s.drv", (LPSTR)szDriver);

    if ((hDrv = LoadLibrary ("PSCRIPT.DRV")) < 32)
        return FALSE;

    if (!(lpfn = GetProcAddress (hDrv, "ExtDeviceMode")))
        return FALSE;

    /* Get the number of bytes needed for the init data */
    numbytes = (*lpfn) (hwnd,
                  hDrv,
                  NULL,
                  (LPSTR)szDevice,
                  (LPSTR)szPort,
                  (LPDEVMODE)NULL,
                  (LPSTR)NULL,
                  0);

    /* Grab some memory for the new data and lock it. */
    hT    = LocalAlloc (LHND,cb);
    lpNew = (LPSTR)LocalLock (hT);

    /* Post the device mode dialog. 0 flag iff user hits OK button */
    if ((*lpfn) (hwnd,
                 hDrv,
                 (LPDEVMODE)lpNew,
                 (LPSTR)szDevice,
                 (LPSTR)szPort,
                 (LPDEVMODE)lpOld,
                 (LPSTR)NULL,
                 flag)==IDOK)

	I am getting an UAE when I call the above.  As I said in an
	earlier posting, I think my problems are in the lpNew structure.

	THE SDK MANUALS ARE UNCLEAR WHETHER TO ALLOCATE A BUFFER (LPSTR)
	OR TO ALLOCATE A STRUCTURE OF DEVMODE.

	Frankly, I'm somewhat confused.

	If anybody can help...please do so.

	Regards |(8>
---
Robert
rdthomps@vela.acs.oakland.edu

bonneau@hyper.hyper.com (Paul Bonneau) (06/12/91)

In article <7007@vela.acs.oakland.edu> rdthomps@vela.acs.oakland.edu (Robert D. Thompson) writes:
>In article <1991Jun10.214915.1973@hyper.hyper.com> bonneau@hyper.hyper.com (Paul Bonneau,,) writes:
>>In article <6931@vela.acs.oakland.edu>
>>rdthomps@vela.acs.oakland.edu (Robert D. Thompson) writes:
>>>
>>>	I seem to be having problems calling a function after
>>>	GetProcAddress()
>>>
>>>	Basically,
>>>
>>>		lpfnFunction = GetProcAddress(...)
>>>
>>>	Then I want to call the function.
>>>
>>>	I remember doing something similar a while back, but I 
>>>	can't seem to get this to work...even with
>>>
>>>		(lpfnFunction)(<argument list>);
>>>
>>>	Any help would be appreciated.
>>>
>>You need to use CallWindowProc() with the lpfn as the first
>>param, followed by the arg list.
>>
>>cheers - Paul Bonneau.
>
>Paul,
>
>	Actually, the SDK sample application MULTIPAD, specifically
>	MPPRINT.C, contains (somewhat) what I am trying to do.
[deleted]

Sorry Robert,

I wasn't paying close enough attention to the content of your
message.  I missed your earlier posting, and I didn't pay
enough attention to the GetProcAddress() call to get the lpfn
in your second posting.  I assumed you were simply calling a
WindowProc, when you really weren't.

cheers - Paul Bonneau.