Receive string values from Win32 API call

Got a problem you cannot solve? Try here.
Post Reply
smilyface
Posts: 12
Joined: Mon Jun 21, 2010 2:55 am

Receive string values from Win32 API call

Post by smilyface »

Hello,

where is an example project which illustrates how to receive string values from Win32 API calls?

Best regards,

Frank

InstallAware 9R2
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Receive string values from Win32 API call

Post by giaviv »

Dear Frank,

Which API function would you like to call?
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
smilyface
Posts: 12
Joined: Mon Jun 21, 2010 2:55 am

Re: Receive string values from Win32 API call

Post by smilyface »

Hi,

this is the function GetPrinterDriverDirectory:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

But it would be great to know a common way to do this.

Best reagrds,

Frank
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Receive string values from Win32 API call

Post by giaviv »

Dear Frank,

This function (and most other WIN32 functions) returns a bool, not a string.
In such case, it is not possible to receive a string value back from the function because it is passed as a pointer and not returned.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
smilyface
Posts: 12
Joined: Mon Jun 21, 2010 2:55 am

Re: Receive string values from Win32 API call

Post by smilyface »

Hello Aviv,

which possibilities are available to get the printer driver directory with InstallAware?

How should be a wrapper function for the api GetPrinterDriverDirectory?

InstallAware don't know a string for return values for functions in c-dlls. What is the common way to retrieve strings?

Frank
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Receive string values from Win32 API call

Post by giaviv »

Dear Frank,

The solution would be to write a DLL that allocates a string buffer, calls the API function, and returns a pointer to the allocated string buffer.
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
smilyface
Posts: 12
Joined: Mon Jun 21, 2010 2:55 am

Re: Receive string values from Win32 API call

Post by smilyface »

Hello Aviv,

>... and returns a pointer to the allocated string buffer
And what should do with this pointer to get the allocated string in a InstallAware variable?

Do you have any example for me? This would be a great help.

Best regards,

Frank
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Receive string values from Win32 API call

Post by giaviv »

You just set the return type to string.

Please provide me with a dll / win32api with a function that returns LPCWSTR and I will create an example for you.

Thanks!
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
smilyface
Posts: 12
Joined: Mon Jun 21, 2010 2:55 am

Re: Receive string values from Win32 API call

Post by smilyface »

Hi,

i found the solution. Thanks for your help.

Best regards,

Frank
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Receive string values from Win32 API call

Post by giaviv »

Sure, Frank. You an share it here if you'd like (so other users can learn too!)
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply