-
May 17th, 2008, 02:40 PM
#1
about String Pointers ??
hi
i work with a c++ dll in vb6...
with a method in dll i can read/write data such as string use pointers.
for exam. i write to memory(dll) 'hello' string ,but when i get pointer to read data ,the string has strange character ?!
does C++ dll convert my string to ANSI ?
also in vb6 if StrPtr(A)=0 ,it means A is nullstring. now is there a way to copy an string value(not null) to null variable using pointer ? specially when we have only pointer of null variable.
thanks
-
May 17th, 2008, 02:42 PM
#2
Re: about String Pointers ??
VB6 doesn't have string pointers, like C+ You can pass by value or by reference. You can have a string array. VB6 is Unicode based as well
-
May 17th, 2008, 03:02 PM
#3
Re: about String Pointers ??
VB6 doesn't have string pointers
but in vb6 we have VarPtr , StrPtr and ObjPtr .
VB6 is Unicode based as well
i know ,but maybe C++ not. and i have problem with convert string from C to vb6.
-
May 19th, 2008, 09:19 AM
#4
Re: about String Pointers ??
To pass string data from and to a dll you declare the parameter ByVal xxx as String.
This may sound illogical but it will pass a real LPSZSTR stringpointer (pointer to a zero terminated string) to the dll function.
Example
Code:
Public Declare Function StringFunc Lib "myDll.dll" ( _
ByVal Buffer As String, _
ByVal Size As Long _
) As Long
If you intend the dll to return data by filling this string you better pass the max length in the Size parameter, so your dll knows how many characters it may put into the Buffer area.
If you pass a parameter ByRef as String you will pass a pointer to a BStr structure which in turn contains the length and a stingpointer to the actual characters. So it is most likely that you see 'strange characters' because it is just some memory conents around the BStr.
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
|