|
-
Nov 5th, 2002, 10:42 AM
#1
Thread Starter
New Member
Passing Strings
Hi,
I'm writing a DLL that needs to be able to call back into my VB app with various information. One of the functions in the VB app is like this:
Public Sub MyCallBackFunction(byval text as string)
I have passed the address of this function into the DLL, and can call other functions perfectly normally if I don't need to pass them a string, and I can return a string from a function in the DLL using the method below, but I can't call back into my vb app passing a string as one of the parameters.
LPVOID PackVBStr(char * InBuffer)
{
LPVOID OutBuffer ;
int BufLen ;
BufLen = GetvbStringLen(InBuffer);
OutBuffer =(char*)malloc((BufLen*2)+1);
memcpy(OutBuffer,InBuffer,((BufLen*2)+1));
return OutBuffer ;
}
USHORT GetvbStringLen(LPVOID InBuffer)
{
char *t;
int count=0;
int BufLen=0;
t = (char*)InBuffer;
while(count<2)
{
if(*t != '\0')
{
count = 0;
BufLen++;
}
else
{
count++;
}
t++;
}
return(BufLen);
}
LPVOID APIENTRY ReturnString()
{
LPVOID ret = PackVBStr("Hello World");
return ret;
}
Any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|