LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview crashes after calling dll

I wrote a DLL (with VC++ 6) that returns a string, which length LabView is not knowing.
And I wrote a VI that calls this DLL within a loop.
The Problem is, LabView runs the VI without problems only for the first time, when I start the VI for the second time LabView crashes with an Windows error.
It is very important for me to rezise the string.

I've attached a zip file with the VI and the VC++ 6 project.

-RobertoHRO
0 Kudos
Message 1 of 2
(2,670 Views)
Hi,

You need to use the DSSetHandleSize function to allocate memory space for your string.

here is a snipit for an ni example:
int32 DynamicStringResize(LStrHandle in_string, int32 size)
{
MgErr error;
int32 i;

// Strings have the first 32 bits determine how many characters are in the string
error = DSSetHandleSize(in_string, sizeof(int32) + size*sizeof(uChar) );
if (error != mFullErr && error != mZoneErr)
{
(*in_string)->cnt=size;
for (i=0; i (*in_string)->str[i]=(uChar)(65+i); //65 is decimal for character 'A'
return 0;
}
else return -1;
}


You can find this example at
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E78F56A4E034080020E74861&p_node=DZ52065&p_submi
tted=&p_rank=&p_answer=&p_source=External

This should help sort your problem
Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 2 of 2
(2,670 Views)