We help IT Professionals succeed at work.

How to declare LPBYTE type Pointer to a structure

bansaldeep
bansaldeep asked
on
I want to call a windows function -

BOOL AddPrinterDriver(
  LPTSTR pName,        // server name
  DWORD Level,         // driver information level
  LPBYTE pDriverInfo   // driver information buffer
);

from my program.
It requires 3rd argument as type LPBYTE which is a pointer to structure
containing printer driver information.The structure is:

typedef struct _DRIVER_INFO_3 {
  DWORD  cVersion;
  LPTSTR pName;
  LPTSTR pEnvironment;
  LPTSTR pDriverPath;
  LPTSTR pDataFile;
  LPTSTR pConfigFile;
  LPTSTR pHelpFile;
  LPTSTR pDependentFiles;
  LPTSTR pMonitorName;
  LPTSTR pDefaultDataType;
} DRIVER_INFO_3, *PDRIVER_INFO_3;

How do i declare a pointer to this structure so that i can populate
structure members and then how to pass this pointer to AddPrinterDriver function?

Comment
Watch Question

Commented:
Try this;
_DRIVER_INFO_3  myInfo3;
// maybe some initialization
memset(&myInfo3, 0, sizeof(_DRIVER_INFO_3));
myInfo3.cVersion = ...;
...
AddPrinterDriver(..,..,(LPBYTE)&myInfo3);
 

Author

Commented:
Great!!!!It works.....
Hello,

Would you mind sharing the working code on this or assist me with a current Issue @
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20446936.html

I am getting a error 4 and it is driving me crazy.

Thank you,
Marcelo