I'm working toward calling a dll created from a vi in a LabWindows/CVI application. The dll requires an LStrHandle so I'm using code I found here.
static LStrHandle MakeLStrHandle(char * text)
{
LStrHandle lvStringHandle;
lvStringHandle = (LStrHandle)DSNewHandle(sizeof(int32) + strlen(text) * sizeof(char));
// Empty the buffer
memset(LStrBuf(*lvStringHandle), '\0', strlen(text));
// Fill the string buffer with stringData
sprintf((char*)LStrBuf(*lvStringHandle),"%s", text);
// Inform the LabVIEW string handle about the size of the stringData
LStrLen(*lvStringHandle) = strlen(text);
return(lvStringHandle);
}
At first it failed to link. I tried adding labview.lib and labviewv.lib and either one allows it to link (What's the difference between them?)
But when I run the program, I get an error creating the DSNewHandle. I get the same type of error regardless of whether I use labview.lib or labviewv.lib.
It looks like I'm not initializing something, but what?