🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How Do I Call Function After GetProcAddress (PROBLEMS WITH

#3182
From: Robert D. Thompson
Date: Tue, 11 Jun 1991 02:58
104 lines
3592 bytes
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
Technical Details
Message-ID: <7007@vela.acs.oakland.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!m.cs.uiuc.edu!vela!rdthomps

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!m.cs.uiuc.edu!vela!rdthomps
From: rdthomps@vela.acs.oakland.edu (Robert D. Thompson)
Newsgroups: comp.windows.ms.programmer
Subject: Re: How Do I Call Function After GetProcAddress (PROBLEMS WITH
Message-ID: <7007@vela.acs.oakland.edu>
Date: 11 Jun 91 02:58:10 GMT
Organization: Oakland University, Rochester MI.
Lines: 104