[quote user="Bruce Reeves SRNS"]sprintf_s( keyinToSend, sizeof(keyinToSend),"MyApp MyTask", mdlSystem_expandCfgVar(fileToFind) );[/quote]
mdlSystem_expandCfgVar has allocated memory to store a string. It has returned a pointer to that dynamically-allocated memory. You have immediately copied the content of that memory to your local variable. When the function exits, the memory allocated by MicroStation is left dangling. Furthermore, you have no handle on that memory, so you can't free it.
Free the memory as advised. But, to do that, you have to assign a local pointer variable...
const char *fileToFind = "$(_USTN_WORKSPACEROOT)Standards\\Data\\myFile.dat\0"; char* expanded = mdlSystem_expandCfgVar(fileToFind); char keyinToSend [MAX_PATH + 22]; sprintf_s (keyinToSend, sizeof (keyinToSend),"MyApp MyTask %s", expanded); mdlSystem_freeCfgVarBuffer (expanded);