locked
Integrating External Excecutable File in Windows Form Help? RRS feed

  • Question

  • Hi Everyone! :)

    I'm currently working on an application that simply, upon clicking a button, opens up an external application inside of the Form. This is what I've got so far:

        Private Const WM_SYSCOMMAND As Integer = 274
        Private Const SC_MAXIMIZE As Integer = 61488
        Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
        Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim proc As Process
            proc = Process.Start("ExampleSplashscreenLoader.exe")
            proc.WaitForInputIdle()
            SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
            SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        End Sub

    The application I want to load is a basic splashscreen loader that, once loaded, opens up another application. When this code is executed, it opens up the splashscreen inside the form and I can move it about within the form only (which is what I want). However, once the splashscreen has loaded, and the primary application is launched, the primary application launches outside of the form like it normally would (not what I want, it must load inside the form). The main application exists as another executable, however it cannot open by itself, it must be opened with the splashscreen launcher. Does anyone know any way around this? The main application is called "MainApplication.exe", the loader is called "ExampleSplashscreenLoader.exe".

    Thanks so much for any help!

    Arrd

    Saturday, October 21, 2017 3:17 PM

Answers

  •  I know this is what you want but,  i will warn you now that it is not a good idea to set a top level window as a child of your application's window.  It can cause several different bugs in the top level window.  Some i have seen several times like selecting text in textboxes not acting right,  menus not acting right,  and more....

     Anyways,  to answer your question,  you would have to monitor the system for new Processes being started so that you could set the one you want as a child of your application's panel.  That can be done a few ways.  One is to start a Timer when the first process is started.  You can use the timer's Tick event to find a Process by its Process Name.  If one is found,  set it as a child of the panel and stop the timer.

     Another way is to use WMI to monitor new processes being started.  This monitors new processes starting and checks to see if it is Notepad,  if it is,  it set it as a child of the Form.

    'You must add a reference to (System.Management)
    Imports System.Management
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private WithEvents mew As ManagementEventWatcher
        Private qe As WqlEventQuery
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
                qe = New WqlEventQuery
                qe.QueryString = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa ""Win32_Process"""
                mew = New ManagementEventWatcher(qe)
                mew.Start()
            Catch ex As Exception
                Trace.WriteLine(ex.ToString)
            End Try
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            mew.Stop()
        End Sub
    
        Private Sub w_EventArrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs) Handles mew.EventArrived
            Invoke(New ProcessStartedDelegate(AddressOf ProcessStarted), CType(e.NewEvent.Item("Targetinstance"), ManagementBaseObject))
        End Sub
    
        Private Delegate Sub ProcessStartedDelegate(mbo As ManagementBaseObject)
    
        Private Sub ProcessStarted(mbo As ManagementBaseObject)
            If mbo.GetPropertyValue("Name").ToString.ToLower = "notepad.exe" Then
                Dim pid As Integer = CInt(mbo.GetPropertyValue("ProcessId").ToString)
                SetParent(Process.GetProcessById(pid).MainWindowHandle, Me.Handle)
            End If
        End Sub
    
        <DllImport("user32.dll")> Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    End Class

      A third way is to use the SetWinEventHook api function to monitor the system for windows being created.  This will have the quickest response time and be more reliable than the first two methods.  This monitors new windows being created and checks to see if it is Notepad,  if it is,  it set it as a child of the Form.

    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private hEventHook As IntPtr
        Private EventHookDel As New WINEVENTPROC(AddressOf EventCallback)
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            hEventHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, IntPtr.Zero, EventHookDel, 0, 0, WINEVENT_OUTOFCONTEXT)
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            UnhookWinEvent(hEventHook)
        End Sub
    
        Private Sub EventCallback(ByVal hWinEventHook As IntPtr, ByVal [event] As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal idEventThread As UInteger, ByVal dwmsEventTime As UInteger)
            If [event] = EVENT_OBJECT_CREATE Then
                Dim p As Process = Process.GetProcesses.Where(Function(x) x.MainWindowHandle = hwnd AndAlso x.MainModule.ModuleName.ToLower = "notepad.exe").FirstOrDefault
                If p IsNot Nothing Then
                    SetParent(hwnd, Me.Handle)
                End If
            End If
        End Sub
    
        Private Const WINEVENT_OUTOFCONTEXT As Integer = &H0
        Private Const EVENT_OBJECT_CREATE As Integer = &H8000
    
        <DllImport("user32.dll")> Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    
        <DllImport("user32.dll")>
        Private Shared Function SetWinEventHook(ByVal eventMin As UInteger, ByVal eventMax As UInteger, ByVal hmodWinEventProc As IntPtr, ByVal pfnWinEventProc As WINEVENTPROC, ByVal idProcess As UInteger, ByVal idThread As UInteger, ByVal dwFlags As UInteger) As IntPtr
        End Function
    
        <UnmanagedFunctionPointer(CallingConvention.StdCall)>
        Private Delegate Sub WINEVENTPROC(ByVal hWinEventHook As IntPtr, ByVal [event] As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal idEventThread As UInteger, ByVal dwmsEventTime As UInteger)
    
        <DllImport("user32.dll")> Private Shared Function UnhookWinEvent(ByVal hWinEventHook As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function
    End Class


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 6:32 PM
  •  For some reason, with the code that I presented to you, I'm only able to open notepad within the form. Is there any way to open up a file that's located on the desktop?

     Do you get an error trying to open the 'ExampleSplashscreenLoader.exe' process or does it just not get set as a child of the panel?

     If it opens and just does not get set as a child of the panel,  that would most likely be because you are not giving the process enough time to open completely before setting it as a child of the panel.  I have seen similar problems many times.  The WaitForInputIdle method does not do that as you would think it would.

     You can try it like below to see if that is the problem.  The Thread.Sleep method will cause your application to wait 5000 milliseconds (5 seconds) before trying to set the ExampleSplashscreenLoader's window as a child of the panel.  5 seconds is just a guess because,  you never know how long a process is going to take to open so,  it is not a good way to do it but,  it will let you test it anyways.  This is why monitoring the system for new processes is a bit better way to go.

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim proc As Process
            proc = Process.Start("ExampleSplashscreenLoader.exe")
    
            Threading.Thread.Sleep(5000) 'this will cause your window's thread to sleep (basically freeze up and be unresponsive) for 5000 milliseconds (5 seconds)
    
            SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
            SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        End Sub



    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 8:58 PM
  • Trying to open anything other than ("notepad.exe") does not load in the form.

    If I set it to: proc = Process.Start("Mozilla Firefox.exe") | for example, or any other application, I get this message (note that I am able to start the application, but the error shows up once I've clicked on 'button1':

    System.ComponentModel.Win32Exception: 'The system cannot find the file specified'.

    Thanks for putting up with my incompetence. ;)

     Most exe's will require you to supply the full path to the exe like "C:\SomeFolder\ProgramA.exe".  Supplying only the filename like "ProgramA.exe" will only work with programs that are in the (Path variable folders) of the environment.

     For example,  open a command prompt and type the word PATH and hit enter.  It will show you a list of paths that operating system looks in for files it knows and/or uses such as Notepad or Calculator.  These are usually folder like "C:\Windows" or "C:\Windows\System32".

     One exception to that is if the exe or executable files are in the same folder as your application's exe.


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 9:44 PM
  • This happens even when I specify exact filepath of a file other than notepad.exe to be opened :`(

     If the exe exists in the path,  it will be found.  Double and Triple check your paths and spelling if it is saying it can't find the file.


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 9:54 PM
  •  Have you done any testing just to see if you can get these processes (by name) and set their parent to your panel? 

     For example,  start your game and let the game window open.  Then run a new test application with 1 panel and 1 button on the form (code below).   See if you can get the actual MainWindowHandle of the process to work in the SetParent api function.

     If that does nothing,  then try using the other process name "Game" instead of "Gameclient2" to see if that process's MainWindowHandle works.  Best to do some basic testing to see if you can get this to work using the Process class first.  If not,  you will need to jump deeper into the win32 api functions to get the actual window handle.

    Imports System.Runtime.InteropServices
    
    Public Class Form1
        <DllImport("user32.dll")> Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim ClientProcess As Process = Process.GetProcessesByName("Gameclient2").FirstOrDefault
            If ClientProcess IsNot Nothing Then
                SetParent(ClientProcess.MainWindowHandle, Panel1.Handle)
            Else
                MessageBox.Show("Process not found.")
            End If
        End Sub
    End Class
    


    If you say it can`t be done then i`ll try it

    Tuesday, October 24, 2017 5:51 PM
  • .... However, when setting the process as game.exe or gameclient2.exe (and I checked the spelling of both processes), your error messagebox popped up "process not found". .....

     Did you use the process names with the .exe added to them.  You can't use the extension on the process name in the GetProcessByName method i used in my example.  It should just be "Gameclient2" or "Game" without the extension.

    If you say it can`t be done then i`ll try it

    Tuesday, October 24, 2017 6:24 PM

All replies

  •  I know this is what you want but,  i will warn you now that it is not a good idea to set a top level window as a child of your application's window.  It can cause several different bugs in the top level window.  Some i have seen several times like selecting text in textboxes not acting right,  menus not acting right,  and more....

     Anyways,  to answer your question,  you would have to monitor the system for new Processes being started so that you could set the one you want as a child of your application's panel.  That can be done a few ways.  One is to start a Timer when the first process is started.  You can use the timer's Tick event to find a Process by its Process Name.  If one is found,  set it as a child of the panel and stop the timer.

     Another way is to use WMI to monitor new processes being started.  This monitors new processes starting and checks to see if it is Notepad,  if it is,  it set it as a child of the Form.

    'You must add a reference to (System.Management)
    Imports System.Management
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private WithEvents mew As ManagementEventWatcher
        Private qe As WqlEventQuery
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
                qe = New WqlEventQuery
                qe.QueryString = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance isa ""Win32_Process"""
                mew = New ManagementEventWatcher(qe)
                mew.Start()
            Catch ex As Exception
                Trace.WriteLine(ex.ToString)
            End Try
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            mew.Stop()
        End Sub
    
        Private Sub w_EventArrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs) Handles mew.EventArrived
            Invoke(New ProcessStartedDelegate(AddressOf ProcessStarted), CType(e.NewEvent.Item("Targetinstance"), ManagementBaseObject))
        End Sub
    
        Private Delegate Sub ProcessStartedDelegate(mbo As ManagementBaseObject)
    
        Private Sub ProcessStarted(mbo As ManagementBaseObject)
            If mbo.GetPropertyValue("Name").ToString.ToLower = "notepad.exe" Then
                Dim pid As Integer = CInt(mbo.GetPropertyValue("ProcessId").ToString)
                SetParent(Process.GetProcessById(pid).MainWindowHandle, Me.Handle)
            End If
        End Sub
    
        <DllImport("user32.dll")> Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    End Class

      A third way is to use the SetWinEventHook api function to monitor the system for windows being created.  This will have the quickest response time and be more reliable than the first two methods.  This monitors new windows being created and checks to see if it is Notepad,  if it is,  it set it as a child of the Form.

    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private hEventHook As IntPtr
        Private EventHookDel As New WINEVENTPROC(AddressOf EventCallback)
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            hEventHook = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, IntPtr.Zero, EventHookDel, 0, 0, WINEVENT_OUTOFCONTEXT)
        End Sub
    
        Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
            UnhookWinEvent(hEventHook)
        End Sub
    
        Private Sub EventCallback(ByVal hWinEventHook As IntPtr, ByVal [event] As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal idEventThread As UInteger, ByVal dwmsEventTime As UInteger)
            If [event] = EVENT_OBJECT_CREATE Then
                Dim p As Process = Process.GetProcesses.Where(Function(x) x.MainWindowHandle = hwnd AndAlso x.MainModule.ModuleName.ToLower = "notepad.exe").FirstOrDefault
                If p IsNot Nothing Then
                    SetParent(hwnd, Me.Handle)
                End If
            End If
        End Sub
    
        Private Const WINEVENT_OUTOFCONTEXT As Integer = &H0
        Private Const EVENT_OBJECT_CREATE As Integer = &H8000
    
        <DllImport("user32.dll")> Private Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    
        <DllImport("user32.dll")>
        Private Shared Function SetWinEventHook(ByVal eventMin As UInteger, ByVal eventMax As UInteger, ByVal hmodWinEventProc As IntPtr, ByVal pfnWinEventProc As WINEVENTPROC, ByVal idProcess As UInteger, ByVal idThread As UInteger, ByVal dwFlags As UInteger) As IntPtr
        End Function
    
        <UnmanagedFunctionPointer(CallingConvention.StdCall)>
        Private Delegate Sub WINEVENTPROC(ByVal hWinEventHook As IntPtr, ByVal [event] As UInteger, ByVal hwnd As IntPtr, ByVal idObject As Integer, ByVal idChild As Integer, ByVal idEventThread As UInteger, ByVal dwmsEventTime As UInteger)
    
        <DllImport("user32.dll")> Private Shared Function UnhookWinEvent(ByVal hWinEventHook As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        End Function
    End Class


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 6:32 PM
  • Thank you so much for your reply! A lot of it's very advanced for me, but I'm going to try to figure out a way to work on your first suggestion (this should be fun :)). For some reason, with the code that I presented to you, I'm only able to open notepad within the form. Is there any way to open up a file that's located on the desktop? Next time I think I'll chose a project better suited to my current knowledge of this language, but until then, I'll have some fun with this.

    Thanks for your help!

    Saturday, October 21, 2017 8:28 PM
  •  For some reason, with the code that I presented to you, I'm only able to open notepad within the form. Is there any way to open up a file that's located on the desktop?

     Do you get an error trying to open the 'ExampleSplashscreenLoader.exe' process or does it just not get set as a child of the panel?

     If it opens and just does not get set as a child of the panel,  that would most likely be because you are not giving the process enough time to open completely before setting it as a child of the panel.  I have seen similar problems many times.  The WaitForInputIdle method does not do that as you would think it would.

     You can try it like below to see if that is the problem.  The Thread.Sleep method will cause your application to wait 5000 milliseconds (5 seconds) before trying to set the ExampleSplashscreenLoader's window as a child of the panel.  5 seconds is just a guess because,  you never know how long a process is going to take to open so,  it is not a good way to do it but,  it will let you test it anyways.  This is why monitoring the system for new processes is a bit better way to go.

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim proc As Process
            proc = Process.Start("ExampleSplashscreenLoader.exe")
    
            Threading.Thread.Sleep(5000) 'this will cause your window's thread to sleep (basically freeze up and be unresponsive) for 5000 milliseconds (5 seconds)
    
            SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
            SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        End Sub



    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 8:58 PM
  • Trying to open anything other than ("notepad.exe") does not load in the form.

    If I set it to: proc = Process.Start("Mozilla Firefox.exe") | for example, or any other application, I get this message (note that I am able to start the application, but the error shows up once I've clicked on 'button1':

    System.ComponentModel.Win32Exception: 'The system cannot find the file specified'.

    Thanks for putting up with my incompetence. ;)

    Saturday, October 21, 2017 9:13 PM
  • Also, the thread.sleep method definitely sounds like an excellent solution to the splashscreen problem. Thanks!
    Saturday, October 21, 2017 9:14 PM
  • This happens even when I specify exact filepath of a file other than notepad.exe to be opened :`(
    Saturday, October 21, 2017 9:23 PM
  • Trying to open anything other than ("notepad.exe") does not load in the form.

    If I set it to: proc = Process.Start("Mozilla Firefox.exe") | for example, or any other application, I get this message (note that I am able to start the application, but the error shows up once I've clicked on 'button1':

    System.ComponentModel.Win32Exception: 'The system cannot find the file specified'.

    Thanks for putting up with my incompetence. ;)

     Most exe's will require you to supply the full path to the exe like "C:\SomeFolder\ProgramA.exe".  Supplying only the filename like "ProgramA.exe" will only work with programs that are in the (Path variable folders) of the environment.

     For example,  open a command prompt and type the word PATH and hit enter.  It will show you a list of paths that operating system looks in for files it knows and/or uses such as Notepad or Calculator.  These are usually folder like "C:\Windows" or "C:\Windows\System32".

     One exception to that is if the exe or executable files are in the same folder as your application's exe.


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 9:44 PM
  • This happens even when I specify exact filepath of a file other than notepad.exe to be opened :`(

     If the exe exists in the path,  it will be found.  Double and Triple check your paths and spelling if it is saying it can't find the file.


    If you say it can`t be done then i`ll try it

    Saturday, October 21, 2017 9:54 PM
  • Hello again IronRazerz!

    I've found the code you gave me really useful to learn from and it has half-solved my problem. However, what do I do if the window that I'd like to embed is running off of 2 processes? (I'm looking at the last code block you wrote by the way):

    so...

     Dim p As Process = Process.GetProcesses.Where(Function(x) x.MainWindowHandle = hwnd AndAlso x.MainModule.ModuleName.ToLower = "notepad.exe" [**and some other process too**]).FirstOrDefault
                If p IsNot Nothing Then

    And how would I make it so that, in the last code block in your solution, a timer would search for, and parent the specified process(es) every 10 seconds, even if they're already supposed to be embedded into the form?

    Thanks so much for your help! :)

    Tuesday, October 24, 2017 12:58 PM
  •  Does this question have something to do with the question you asked yesterday,  the one trying to embed Firefox in the panel which wont work if there is already an instance of firefox opened?

     Is it just firefox that you want to embed in your panel?

     That will require some special handling to keep track of visible windows that are opened on the desktop instead of the actual Processes that you find.



    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, October 24, 2017 5:05 PM
    Tuesday, October 24, 2017 5:05 PM
  • No, Firefox was just an example of that certain issue - the fact that I could only open notepad within the form itself (since fixed). I'm actually trying to open a video game inside the form, however when I open the video game, at first there's a splash screen that appears, once the splash screen has finished loading the game's resources, the main game client opens (in a normal windows form, by the way - not fullscreen). The game client relies on two processes (let's call the first one of them "Game.exe" and the other one "Gameclient2.exe". Only the game's splash screen is confined to my form and the succeeding main client window opens outside of the form.

    Thanks

    Tuesday, October 24, 2017 5:16 PM
  •  Have you done any testing just to see if you can get these processes (by name) and set their parent to your panel? 

     For example,  start your game and let the game window open.  Then run a new test application with 1 panel and 1 button on the form (code below).   See if you can get the actual MainWindowHandle of the process to work in the SetParent api function.

     If that does nothing,  then try using the other process name "Game" instead of "Gameclient2" to see if that process's MainWindowHandle works.  Best to do some basic testing to see if you can get this to work using the Process class first.  If not,  you will need to jump deeper into the win32 api functions to get the actual window handle.

    Imports System.Runtime.InteropServices
    
    Public Class Form1
        <DllImport("user32.dll")> Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
        End Function
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim ClientProcess As Process = Process.GetProcessesByName("Gameclient2").FirstOrDefault
            If ClientProcess IsNot Nothing Then
                SetParent(ClientProcess.MainWindowHandle, Panel1.Handle)
            Else
                MessageBox.Show("Process not found.")
            End If
        End Sub
    End Class
    


    If you say it can`t be done then i`ll try it

    Tuesday, October 24, 2017 5:51 PM
  • Thank you, I'll go try out a few tests, I'll let you know how it goes in 10 minutes. Cheers :)
    Tuesday, October 24, 2017 5:55 PM
  • So I made the form using the code you kindly wrote. I set the process as notepad first, ran the test, upon clicking the button the notepad was confined to the panel (perfect!). However, when setting the process as game.exe or gameclient2.exe (and I checked the spelling of both processes), your error messagebox popped up "process not found". I don't understand, it's bizarre! How do I get the "actual window handle", I'm not familiar with this. Thanks again.
    Tuesday, October 24, 2017 6:08 PM
  • I waited for the game to load out of the splash screen by the way.
    Tuesday, October 24, 2017 6:09 PM
  • .... However, when setting the process as game.exe or gameclient2.exe (and I checked the spelling of both processes), your error messagebox popped up "process not found". .....

     Did you use the process names with the .exe added to them.  You can't use the extension on the process name in the GetProcessByName method i used in my example.  It should just be "Gameclient2" or "Game" without the extension.

    If you say it can`t be done then i`ll try it

    Tuesday, October 24, 2017 6:24 PM
  • Oh my god. What an absolute saint. Thank you, thank you. I hope my words aren't flushed of their effect simply because their being transmitted online - I am truly grateful. I will remember IronRazerz for the rest of my life. I doubt this will be the end of this given the unusual nature of this feature that you built - there are bound to be issues. But until then, thank you!

    Tuesday, October 24, 2017 7:32 PM
  • Oh my god. What an absolute saint. Thank you, thank you. I hope my words aren't flushed of their effect simply because their being transmitted online - I am truly grateful. I will remember IronRazerz for the rest of my life. I doubt this will be the end of this given the unusual nature of this feature that you built - there are bound to be issues. But until then, thank you!

     You're welcome.  I am glad i could help.  8)

      Does this mean that you are set for now or is there a part that you asked that still is not solved?

    If you say it can`t be done then i`ll try it

    Tuesday, October 24, 2017 8:03 PM
  • Every problem I have had so far you have solved! Currently I'm just applying a few optimizations - I'm using the SetWindowPos api function to make it so that the titlebar of the now embedded application is not visible to the user. I've also implemented a timer, so after the timer has ticked passed the estimated splash screen duration, the main window is then embedded (as opposed to button1_clickevent). Next I just need to make it so that that aforementioned timer also dictates when the game window becomes visible (just for tidiness sake) - I am in the process of doing this. I'm basically doing everything that a person with little knowledge (i.e. me) can do.

    All in all, it's all coming together thanks to you. No issues currently :D

    Tuesday, October 24, 2017 8:26 PM