If it is of any value, you can create a new BSTR with ANSI to Unicode conversion using a single API call:
Declare Function SysAllocStringByteLen Lib "oleaut32" (ByVal Ptr As Long, ByVal Length As Long) As String
So code posted by VBClassicRocks would shorten to:You may even want to call it directly instead of wrapping into a functionCode:Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As String) As Long Private Declare Function SysAllocStringByteLen Lib "oleaut32" (ByVal Ptr As Long, ByVal Length As Long) As String Public Function StrFromPtr(ByVal lpStr As Long) As String StrFromPtr = SysAllocStringByteLen(lpStr, lstrlen(lpStr)) End Function![]()




Reply With Quote