I have a sample function from a native code
HRESULT getSampleFunctionValue(_Out_ LPWSTR * argument)
This function outputs the value in argument. I need to call it from the Managed code
[DllImport("MyDLL.dll", EntryPoint = "getSampleFunctionValue", CharSet = CharSet.Unicode)]
static extern uint getSampleFunctionValue([MarshalAsAttribute(UnmanagedType.LPWStr)] StringBuilder argument);
This returns garbage value. AFAIK the original C function does not create string using CoTaskMemAlloc. What is the correct call?
Any help will be appreciated.