DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Running another executable inside a winform

    Is there a way to run an executable inside a winform? I know I can start an executable using system.diagnostics.process, but how can I keep it inside my winform as part of the application, and not show as a completely different application.
    Sorry if this seems to simple. I'm a newbie to winforms.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    Try this. For this example, I'm useing Notepad. Replace the executable for your own needs.
    Code:
    Dim proc As Process 
    
        Private Const WM_SYSCOMMAND As Integer = 274
        Private Const SC_MAXIMIZE As Integer = 61488   
    
        <Runtime.InteropServices.DllImport("user32.dll")> _
    
        Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    
        End Function 
    
        <Runtime.InteropServices.DllImport("user32.dll")> _
    
        Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    
        End Function
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            proc = Process.Start("notepad")
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            SetParent(proc.MainWindowHandle, Me.Panel1.Handle)
    
            SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    
        End Sub
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. automatic running a C++ executable
    By tdas in forum C++
    Replies: 3
    Last Post: 11-02-2005, 03:04 PM
  2. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 10:06 AM
  3. Replies: 3
    Last Post: 05-27-2001, 04:10 AM
  4. Data Type Mismatch
    By maria in forum VB Classic
    Replies: 0
    Last Post: 05-01-2001, 06:37 PM
  5. Running an ASP inside OUTLOOK
    By snake-eyes in forum Web
    Replies: 5
    Last Post: 06-17-2000, 06:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links