Byte Array C to VB6


Author: 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)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 85 + 39 = ? followed by the letter: B 



About Me
More Blogs
Main Site
Posts: (All)
2024 ( 3 )
2023 ( 9 )
2022 (4)
     More VB6 - C data passing
     Vb6 Asm listing
     Byte Array C to VB6
     Planet Source Code DVDs
2021 (2)
     Obscure VB
     VB6 IDE SP6
2020 (4)
     NTFileSize
     BSTR from C Dll to VB
     Cpp Memory Manipulation
     ActiveX Binary Compatability
2019 (5)
     Console tricks
     FireFox temp dir
     OCX License
     Extract substring
     VB6 Console Apps
2018 ( 6 )
2017 ( 6 )
2016 ( 22 )
2015 ( 15 )
2014 ( 25 )
2013 ( 4 )
2012 ( 10 )
2011 ( 7 )
2010 ( 11 )
2009 ( 3 )