Additional information: A call to PInvoke function 'Test Embed!Test_Embed.Form1::SetWindowLong' 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.
Hosting EXE Applications in a WinForm project
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start(@"C:\Users\Conmeo\AppData\Roaming\Microsoft\Windows\Start Menu\LDPlayer-1.lnk");
Thread.Sleep(500);
p.WaitForInputIdle();
appWin = p.MainWindowHandle;
SetParent(appWin, this.Handle);
// Process p = Process.Start(@"D:\ChangZhi\LDPlayer\dnplayer.exe");
// Remove border and whatnot
SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
// Move the window to overlay it on this window
MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
}
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
private static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong);