|
-
Jul 22nd, 2012, 05:54 PM
#1
Thread Starter
New Member
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:
Public Class Form1 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 Const WM_SYSCOMMAND As Integer = 274 Private Const SC_MAXIMIZE As Integer = 61488 Dim proc As Process Dim AppPath As String Dim strPath As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AppPath = "C:\Users\User\Documents\Visual Studio 2010\Projects\Z26.exe" strPath = ""C:\Users\User\Documents\Visual Studio 2010\Projects\3d_tictac.bin" proc = Process.Start(AppPath) proc.WaitForInputIdle() SetParent(proc.MainWindowHandle, Panel1.Handle) SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0) End Sub 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|