Visual C++ DLL won't work with VB
Didn't know where to post this as it's both VB and VC code, heres goes:
I have a DLL which contains this function:
void _stdcall cryptArray(unsigned char *bArray, long bArrayLen)
{
for (long i=0; i<=bArrayLen; ++i)
{
bArray[i]=bArray[i]^5;
}
}
To use this is Visual Basic, I call it with a procedure similar to this:
Public Declare Sub cryptArray Lib "C:\My Documents\Visual C++\XorEnc DLL\Debug\XorEnc DLL.dll" (Bytes As Byte, NumBytes As Long)
Dim Bytes(0 To 3) As Byte
For t = 0 To 3
Bytes(t) = t
Next
cryptArray Bytes(0), 4
When I do this I get a "Vb6 has caused an error..." in the above DLL.
Can anyone see where I've gone wrong?
Re: Visual C++ DLL won't work with VB
Quote:
Originally posted by CactusCat
Didn't know where to post this as it's both VB and VC code, heres goes:
I have a DLL which contains this function:
void _stdcall cryptArray(unsigned char *bArray, long bArrayLen)
{
for (long i=0; i<bArrayLen; ++i)
{
bArray[i]=bArray[i]^5;
}
}
To use this is Visual Basic, I call it with a procedure similar to this:
Public Declare Sub cryptArray Lib "C:\My Documents\Visual C++\XorEnc DLL\Debug\XorEnc DLL.dll" (ByVal Bytes As Long, ByVal NumBytes As Long)
Dim Bytes(0 To 3) As Byte
For t = 0 To 3
Bytes(t) = t
Next
cryptArray VarPtr(Bytes(0)), 4
When I do this I get a "Vb6 has caused an error..." in the above DLL.
Can anyone see where I've gone wrong?