I\'m really confused about passing strings from VBA to C++. Here\'s the VBA code:
Private Declare Sub passBSTRVal Lib \"
This is just an illustration to Simon's answer. It shows how to call a native DLL that has parameters of type LPWSTR. As a simple example, I use GetWindowsDirectoryW. As Simon pointed out, always use the "W" version of native DLLs.
Declare PtrSafe Function GetWindowsDirectoryW Lib "kernel32" _
(ByVal lpBuffer As LongPtr, ByVal nSize As Long) As Long
Sub TestGetWindowsDirectoryW()
Dim WindowsDir As String
WindowsDir = Space$(256)
GetWindowsDirectoryW StrPtr(WindowsDir), 256
MsgBox WindowsDir
End Sub