I have written a C++ DLL with the following function exported
extern "C" BOOL WINAPI SetUserPassword(const char* u, const char* p)
When calling this from C# I am using the following code
[DllImport("mydll.dll")]
private static extern int SetUserPassword(String user, String password);
Now when SetUserPassword
is called I only get the first letter of each parameter. I did some googling and found that String
was perhaps not the best to use so tried using IntPtr and Marshal.StringToBSTR()
but this didn't work either.
How should this be structured correctly? I am able to modify the C++ DLL if required.