Basic is not always slower than assembler
FUNCTION BSTR_to_FBstr Alias "BSTR_to_FBstr" (ByVal srcBSTR AS BSTR) AS String Export
Dim AS LONG i
Dim AS Byte PTR j
Dim AS STRING s
Asm
mov eax, [srcBSTR]
mov ecx, [eax-4]
mov [i], ecx
End ASM
If i>0 THEN
s = Space(i)
j = StrPtr(s)
Asm
mov esi, [srcBSTR]
mov edi, [j]
mov ecx, [i] 'length of data
cld
Shr ecx, 1
rep movsw
jnb NotNext
movsb
NotNext:
End ASM
End If
Function = s
End Function
This is much faster though written in basic and not with inline code
FUNCTION BSTR_to_FBstr2 Alias "BSTR_to_FBstr2" (Byval s AS bstr ptr) AS String Export
Function = *Cast(zstring Ptr,s)
End Function