NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how yo load a string from the dll call text file

I'm using the VC6.0 and teststand 3.1.
I want to load a string from text file by call dll, if  have a vc sample it is much appreciated.
 
thank you in advance.
0 Kudos
Message 1 of 4
(3,097 Views)
I have wrote a dll like this:
char __declspec (dllexport) *ReadTextFile()
{
   
 CString s="aaaaaabbbbbb";
 char *p = (char *)(const char *)s;
 return p;
 
}
 
I want to load the string from dll into teststand,but unforturnately that I cannot found any return in the teststand,
 
anyone can help me what's wrong or give me a sample code for this functionality ?
 
thank you in advance.
0 Kudos
Message 2 of 4
(3,056 Views)

Hi,

Can you show a jpg of the specify dialog or post the sequencefile?

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 3 of 4
(3,055 Views)

That is one of the few prototypes that TestStand doesn't support because TestStand limits return values to numerics and boolean data types.

However, you can easily work around this by creating a wrapper function around your existing function that instead returns the string via a parameter.

Your next issue is what is the caller expected to do with the string pointer. If returned pointer is to a buffer the caller does not free, then there is no problem.

If the caller is expected to free the buffer, TestStand can't do that because it doesn't know what memory manager to use to free it. In that case, your wrapper function would copy the string into the string parameter and then free it. In the TestStand call to the wrapper, you would have to specific an adequate string size to receive the copy.

Note that in your sample function, you return in internal pointer to data in the CString object which will be destructed when the function exits, thus freeing the memory that contains the string. This is incorrect.  You could make the CString a static variable to avoid the problem if you are ok with it holding onto the string data between calls and if you know you won't call the function from multiple threads at the same time.

0 Kudos
Message 4 of 4
(3,046 Views)