Byte Array C to VB6Author: Dave Date: 01.07.22 - 9:06am Quick example on how to return a byte array from C to VB6. This is done using a safe array.
LPSAFEARRAY __stdcall Decode(char* data){ #pragma EXPORT LPSAFEARRAY ret = NULL; std::vector<unsigned char> vch; if(data!=NULL && strlen(data) > 0 ){ if(DecodeBase58(data, vch)){ HRESULT h = PackBytes(vch.size(),(const BYTE*)&vch[0], &ret); if(h == S_OK) return ret; } } return NULL; } Private Declare Function Decode Lib "b58.dll" (ByVal encStr As String) As Byte() dim b() as byte b() = Decode(buf) If AryIsEmpty(b) Then MsgBox "Decode failed" Else MsgBox "Decoded data: " & vbCrLf & _ "Str Data = " & StrConv(b, vbUnicode, &H409) & vbCrLf & _ "Hex Data= " & b2h(b) End If Comments: (0) |
About Me More Blogs Main Site
|
|||||||||||||||||||||||||||||||