|
-
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?
-
Nov 5th, 2002, 11:36 AM
#2
Frenzied Member
See your thread in the VB forum.
-
Nov 5th, 2002, 03:07 PM
#3
Search this forum, it has been discussed several times. Search especially for BSTR.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 5th, 2002, 03:21 PM
#4
Frenzied Member
I BSTR'ed him up in the other forum
-
Nov 5th, 2002, 03:26 PM
#5
That's gotta hurt
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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
|