Hello CodeProject,
I want to embed a game(like : GTA etc.) inside my Forms Application, I know how you do it with simple Windows Forms Applications using the following Code ::
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;
private void button1_Click(object sender, EventArgs e)
{
try
{
Process p = Process.Start(textBox1.Text,textBox1.Text);
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1.Handle);
}
catch (Exception ex)
{
MessageBox.Show("ERROR DUDE!!!!!\n" + ex.Message);
}
}
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
It works for Normal Applications like Notepad,QEMU etc.
But for complex applications like Games,Browsers,etc. I get the following problems
1) For mostly Games, They are Not able to load resources properly, for instance take IGI,
when I start igi2.exe from my application I get a error message saying
"COULD NOT LOAD FILE : LOCAL:weapons.res"
Same goes for Games that require resources to be loaded from HDD.
2)When I start chrome,iexplore,explorer.exe or any such complex application my Form is unable to catch it. Also My error handler show the following message(sometimes) :
"ERROR DUDE!!!!!!!!!!!!!!!!!
Process has exited"
Any Solution/Suggestion to this?
Any help would be appreciated
~Sids123