If I used, for example
Code: Select all
AES( AES128, "Address.txt", "Password", 0 )
where PB was expecting the 2nd and 3rd parameter to be PB dynamic strings ByVal then I got into trouble.
Returned PB's dll to its former glory ie ByVal As String
With this
Code: Select all
#include once "win/ole2.bi"
Function StrToBSTR( FB_String As String) As BSTR
Return SysAllocStringByteLen( FB_String, Len(FB_String) )
End Function
' Get PB's library
Dim AS BSTR A0, A1, P
A0 = StrToBSTR("Address.txt")
A1 = StrToBSTR("Address.txt.aes")
P = StrToBSTR("Password")
AES( AES128, A0, P, 0)
Print "Wait"
Sleep
AES( AES128, A1, P, 0 )
SysFreeString(A0)
SysFreeString(A1)
SysFreeString(P)
Print "Done"
Sleep
I saw Address.txt.aes created. On the Wait I deleted Address.txt and pressed Enter. I then saw Address.txt being created and it was the same as the original Address.txt.
So I am now using PB's library as originally written and in FB all we need do is use StrToBSTR( <string> ) instead of <string>.
Thanks José for SysAllocStringByteLen.
Added: The better solution for me is the first one where PB's library is re-compiled so that we can write FB code as normal. The second solution comes into it's own where we cannot re-compile a library expecting BSTR strings.