01-10-2013 11:19 AM
Hello,
I'm calling a function exported by a C++ dll which returnes a pointer of char. In my call in teststand, a variable of Object Reference is used to get the returned pointer.
I now need to parse this object to a string or an array of string but don't find any info on how to do it.
Your help would be greatly appreciated.
Thanks,
Dave
01-11-2013 12:08 AM
01-11-2013 09:57 AM
@daveinca wrote:
Hello,
I'm calling a function exported by a C++ dll which returnes a pointer of char. In my call in teststand, a variable of Object Reference is used to get the returned pointer.
I now need to parse this object to a string or an array of string but don't find any info on how to do it.
Your help would be greatly appreciated.
Thanks,
Dave
Returning a char* from a C function is a bit tricky when mixing programming languages since who allocated and who should free the underlying memory for the string is not well defined. The easiest thing for you to do would be to write a utility function in a C/C++ dll that teststand can call that takes this pointer and fills in a string buffer also passed in by TestStand.
-Doug
01-11-2013 11:59 AM
Hi Sathish, Doug,
Thanks for your reply.
Unfortunately, we can't add any extra code/module because of our strict policy here which is why I've been looking for a way in teststand only.
Dave
01-11-2013 01:19 PM - edited 01-11-2013 01:19 PM
This is a bit of hack, but you could configure a TestStand C/C++ Adapter step to call MultiByteToWideChar in the system Kernel32.dll. And for the source string you can pass your pointer type and for the wide character destination string set the parameter type to Unicode String Buffer.
This should work and get around your "no extra code modules" restriction since kernel32.dll is an OS dll that will exist on every machine.
-Doug