Quote Originally Posted by Freelancer View Post
"PInvokeStackImbalance was detected
Message: A call to PInvoke function 'DevicatorServer!Api::SendMessage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."
Api.cs:
Code:
[DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr _WindowHandler, int _cmd);
    [DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr _WindowHandler, int _WM_USER, Keys _data);
    [DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr _WindowHandler, int _WM_USER, char key, IntPtr wParam);
According to msdn http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
SendMessage has 4 parameters. So unless C# uses default parameters, only the last function header is correct.

So try changing all calls to it, to include a 4th parameter
Cmd.cs: line 37 Api.SendMessage(this.hProcess.MainWindowHandle, 0x100, Keys.Enter); ->
Api.SendMessage(this.hProcess.MainWindowHandle, 0x100, Keys.Enter, null);