|
-
Dec 3rd, 2002, 09:47 AM
#1
Thread Starter
Hyperactive Member
C++ types in VB ?
Hi, I found this Base64 dll written in C++ but I need to call it's functions from VB. Most of the variable types I can figure out and get to work, but there's a couple that I don't know how to translate into VB and could use some help. The list is below.
Code:
UINT cb = ByVal cb As Long
LPCTSTR lpInput = ByVal lpInput As String ?
LPUINT lpEqualSigns = ByRef lpEqualSigns As Long ?
LPCBYTE lpInput = ?? (supposed to be the string to encode)
LPTSTR lpOutput = ?? (supposed to be the output buffer, I'm guessing it would be a string of spaces)
LPCTSTR lpInput = ??
LPBYTE lpOutput = ??
BASE64CALLBACK lpEndCallback = ??
LPVOID lpvParam = lpvParam As Any ?? (ByVal/ByRef?)
If anyone can shed some light on this I would really appreciate it. I'm trying to get in contact with the author but I don't know if I will be able to.
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
-
Dec 3rd, 2002, 09:53 AM
#2
Retired VBF Adm1nistrator
This is a guess by the way 
UINT cb = ByVal cb As Long
LPCTSTR lpInput = ByVal lpInput As String ?
LPUINT lpEqualSigns = ByRef lpEqualSigns As Long ?
LPCBYTE lpInput = ByRef byteArray() As Byte
LPTSTR lpOutput = ByRef strOutput As String
LPCTSTR lpInput = ByVal strInput As String
LPBYTE lpOutput = ByRef byteOutput() As Byte
BASE64CALLBACK lpEndCallback = ByVal lpEndCallBack As Long
strOutput would probably have to be made a big long string of spaces before you start.
byteArray() and byteOutput() are both byte arrays
And lpEndCallBack is a pointer to a function
-
Dec 3rd, 2002, 10:11 AM
#3
Thread Starter
Hyperactive Member
Thanks for the input plenderj,
I tried byte arrays but vb is still crashing (getting invalid page faults, yay!).
Does anyonek now if there some special way to place a string into a byte array that needs to be done? I just looped through getting the Asc() of each char. lpOutput is a null-terminated string of spaces.
This is the declaration in my module
VB Code:
Declare Function Base64EncodeA Lib "Base64" (lpInput() As Byte, _
ByVal cbInput As Long, ByRef lpOutput As String, _
ByVal cbOutput As Long) As Boolean
And here it is in C++
Code:
BOOL BASE64API Base64EncodeA(LPCBYTE lpInput, UINT cbInput, LPSTR lpOutput, UINT cbOutput)
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
-
Dec 3rd, 2002, 10:30 AM
#4
Retired VBF Adm1nistrator
To create byte arrays and vice-versa.
VB Code:
Public Sub StrToAry(ByVal strIn As String, ByRef aryOut() As Byte)
aryOut = StrConv(strIn, vbFromUnicode)
End Sub
Public Sub AryToStr(ByRef aryIn() As Byte, ByRef strOut As String)
strOut = StrConv(aryIn, vbUnicode)
End Sub
And the invalid page fault could be caused by an invalid pointer to a function.
That always crashes applications when it isn't done correctl.
-
Dec 3rd, 2002, 10:38 AM
#5
Thread Starter
Hyperactive Member
I tried converting to unicode, still no luck.
And the invalid page fault could be caused by an invalid pointer to a function.
Does that mean you think the problem would be an invalid pointer in the dll iself, or one of my parameters is an invalid pointer?
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
-
Dec 3rd, 2002, 10:44 AM
#6
Retired VBF Adm1nistrator
I would have to say its probably a problem on your side 
To get a pointer to a function :
VB Code:
Private Sub Form_Load()
Dim myPointer As Long
myPointer = getAddressOf(AddressOf Me.myFunction)
End Sub
Public Function getAddressOf(ByVal n As Long) As Long
getAddressOf = n
End Function
Public Function myFunction()
'' some code here
End Function
So you would pass myPointer to the DLL.
Now, I don't know what its supposed to do with the pointer.
I'd guess it just calls it after its done.
But that might not be the case.
It could be that you have to have a properly formatted function to accept parameters back from the DLL.
You'd really have to check the documentation of the DLL itself.
-
Dec 3rd, 2002, 10:51 AM
#7
Thread Starter
Hyperactive Member
Hmm ok, I guess I'll have to try and get more information from the author..if I can track him down. Thanks anyways plenderj.
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
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
|