Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[Help] Embed exe to vb.net project filter_list
Author
Message
RE: [Help] Embed exe to vb.net project #3
You can embed any other process by changing the ParentHandle from the process to something like picturebox1 (that is in your form).

imports:
Code:
Imports System.Diagnostics
Imports System.Text
Imports System.Runtime.InteropServices
incorporate user32.dll functions
Code:
Private Declare Function SetParent Lib "user32" (ByVal hwndChild As IntPtr, ByVal hwndNewParent As IntPtr) As Integer
Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer


notepad example: (the principle is the same for all GUIs)
Code:
Private Sub run_notepad()
    Dim notepad As New Process
    notepad.StartInfo.FileName = "notepad.exe"
    notepad.Start()
    Do Until notepad.WaitForInputIdle = True
        Application.DoEvents()
    Loop
    embed("notepad")
End Sub
    
Private Sub embed(byval processname as string)
    For Each p As Process In Process.GetProcesses()
        If (p.ProcessName.Contains(processname)) Then
            Dim handle As IntPtr = p.MainWindowHandle
            SetParent(handle, PictureBox1.Handle)
            ShowWindow(handle, 3) ' maximize the exe to dock it. (and remove borders)
        End If
    Next
End Sub

Reply





Messages In This Thread
[Help] Embed exe to vb.net project - by alaa92 - 01-17-2014, 02:06 AM



Users browsing this thread: 1 Guest(s)