Page 1 of 1

Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 4:29 am
by smilyface
Hello,

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

Best regards,

Frank

InstallAware 9R2

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 5:01 am
by giaviv
Dear Frank,

Which API function would you like to call?

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 6:52 am
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

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 7:56 am
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.

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 8:51 am
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

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 10:09 am
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.

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 12:12 pm
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

Re: Receive string values from Win32 API call

Posted: Tue Apr 05, 2011 12:56 pm
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!

Re: Receive string values from Win32 API call

Posted: Wed Apr 06, 2011 6:39 am
by smilyface
Hi,

i found the solution. Thanks for your help.

Best regards,

Frank

Re: Receive string values from Win32 API call

Posted: Wed Apr 06, 2011 11:53 am
by giaviv
Sure, Frank. You an share it here if you'd like (so other users can learn too!)