Hello,
I am currently messing around with some sample code I found
It is about linking VB and CPP through DLL's
http://www.flipcode.com/articles/article_vbdlls.shtml
There is a string embaded in a strunct.
There is a function in a DLL that takes this struct.
This struct comes from a Visual Basic application.
My code changes this string.
But when I output the string in VB i can only see its first character.
I'm trying it for two hours now, any suggestions on this would help.
Thanks for the help in advance
void __declspec(dllexport) CALLBACK StructExample(testStruct *data)
{
data->shortVar = 1;
data->ucharVar = 'b';
data->floatVar = (float)3.4;
data->stringVar = ChartoBSTR("Overwrite");
}
////////// Convert a Character Array to a BSTR String //////////
BSTR ChartoBSTR(char* String)
{
int Len = strlen(String);
unsigned short FinalStr = new unsigned short[Len];
MultiByteToWideChar(CP_ACP,
0,
String,
Len,
FinalStr,
Len);
return(FinalStr);
}