|
-
July 10th, 2012, 05:15 AM
#5
Re: Passing UDT from VB 6.0 to C++ DLL
 Originally Posted by user65536
Thanks for checking thigns out.
I'm pretty sure VB Long is 4 bytes, Double is 8 bytes.
you actually are right.. VB.NET Long = 8 bytes in VB6 = 4 bytes.. Havn't done VB6 in a long time..
 Originally Posted by user65536
I have tried this
Code:
Public Type HASHINFO
pHash As String
szPassword As String
nPasswordLen As Long
szSalt As String
nSaltLen As Long
szName As String
nNameLen As Long
dwFlags As Long
End Type
Dim udt As HASHINFO
udt.szPassword = "test"
udt.nPasswordLen = 4
udt.szSalt = "test"
udt.nSaltLen = 4
udt.szName = "test"
udt.nNameLen = 4
udt.dwFlags = &H0
test = GetHash(udt)
End Sub
I'm not sure if I need to specify something for udt.pHash, have tried various things and it still crashes.
You will need to assign the right amount of space for the Hash to be put in (32 Byte hash ?) as the C DLL cannot assign new/ more memory to the referenced Datatype.
You were on the right track with the Null (&H0) termination..
But something else i'm thinking is that VB stores stings in Unicode (2 bytes per char) and the char array in C is expecting one byte per char.. (this may need clarification from a C Expert) ...
in this case an array of byte may be better to use, and you load the ASCII val of each char in the string to the byte array..
You will have to play with it a little, if your Defs and Variable lengths are out by one, it will crash ...
try this for debugging
Code:
Debug.print len(udt)
After you've assigned all the values and then see if it matches what you should have...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
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
|