Results 1 to 18 of 18

Thread: Open file with external exe file inside VB form

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2012
    Posts
    14

    Open file with external exe file inside VB form

    Hi,

    I'm a newbie here and I have a problem which I which to share. I wish to open a file inside a form using an external program.

    I have looked on the web for a solution but I am having only partial success. Here's the code I am using below:

    vb Code:
    1. Public Class Form1
    2.     Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    3.     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
    4.     Private Const WM_SYSCOMMAND As Integer = 274
    5.     Private Const SC_MAXIMIZE As Integer = 61488
    6.     Dim proc As Process
    7.     Dim AppPath As String
    8.     Dim strPath As String
    9.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10.         AppPath = "C:\Users\User\Documents\Visual Studio 2010\Projects\Z26.exe"
    11.         strPath = ""C:\Users\User\Documents\Visual Studio 2010\Projects\3d_tictac.bin"
    12.         proc = Process.Start(AppPath)
    13.         proc.WaitForInputIdle()
    14.  
    15.         SetParent(proc.MainWindowHandle, Panel1.Handle)
    16.         SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    17.     End Sub
    18. End Class

    If I run the code as above, the exe opens in my form which is what I want. However if I change the line, proc = Process.Start(AppPath) to, proc = Process.Start(AppPath,strPath) so that I open the BIN file, the file is not opened within the form but instead in a new window. If anyone could help me with this problem that would be awesome.
    Thanks
    Last edited by Siddharth Rout; Jul 22nd, 2012 at 06:01 PM. Reason: Added Code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width