How are you calling the DLL? Is it using the "Private Declare" method. Try to change the parameter type. Instead of using "Byval var As String", make it a "Byref var as Any" and pass a pointer to a byte array to it.
This is the original code (for example)
Code:
Private Declare Function GetWindowsDirectoryW Lib "kernel32" ( _
ByVal lpBuffer As String, ByVal nSize As String) As Long
Private Sub Form_Load()
Dim strText As String
strText = Space(255)
Call GetWindowsDirectoryW(strText, 255)
MsgBox strText
End Sub
It will give the result same as yours (as I can understand ur problem). Make the changes like this
Code:
Private Declare Function GetWindowsDirectoryW Lib "kernel32" ( _
ByRef lpBuffer As Any, ByVal nSize As String) As Long
Private Sub Form_Load()
Dim strText As String, bArrStr() As Byte
bArrStr = Space(255)
Call GetWindowsDirectoryW(bArrStr(LBound(bArrStr)), 255)
strText = bArrStr
MsgBox strText
End Sub
Hope it will help you
Bookmarks