简体   繁体   English

在VB.NET中的面板内部运行进程

[英]Running process inside a panel in VB.NET

Is there any way run a jar (or any other process) file inside a panel in vb.net? 有什么办法可以在vb.net的面板中运行jar(或任何其他进程)文件?

I am trying something like this: 我正在尝试这样的事情:

Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Threading

Public Class FGRUPOS

    <DllImport("user32.dll")> Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    End Function

   Private Sub FGRUPOS_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim p As Process
        p = Process.Start("java.exe", "-jar processo.jar")
        Threading.Thread.Sleep(500)
        SetParent(p.MainWindowHandle, panel1.Handle)
    End Sub
End Class

But it is not working. 但这是行不通的。

The code bellow (from vb.net Launch application inside a form ) does the trick: 下面的代码(来自vb.net Launch应用程序,位于form内 )可以达到目的:

Public Class FGRUPOS

    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

    Friend Sub Rodar_Processo()
        Dim p As System.Diagnostics.Process
        p = Process.Start("notepad.exe")
        p.WaitForInputIdle()
        SetParent(p.MainWindowHandle, pnGrupo.Handle)
        SendMessage(p.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
        Me.BringToFront()
   End Sub
End Class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM