在vb,net的窗口下运行外部程序 [英] Run an external program under a window in vb,net

查看:204
本文介绍了在vb,net的窗口下运行外部程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的程序中运行ms word application。我已经调用了exe但是我想在框架下运行意味着我不想显示border.or任何方法来删除外部exe的框架或边框。以下是我得到但不工作的示例代码

 Public Class Form1 
Inherits System.Windows.Forms.Form
声明函数ShowWindow Lib user32(ByVal hWnd As System。 IntPtr ,ByVal nCmdShow As Integer)As Boolean
Private Const SW_MINIMIZE As Integer = 6
Private Const SW_MAXIMIZE As Integer = 3
Private Const SW_RESTORE As Integer = 9

声明函数SetParent Lib user32(ByVal hWndChild As System。 IntPtr ,ByVal hWndNewParent As System。 IntPtr )As System。 IntPtr
#Region Windows窗体设计器生成的代码


Private Sub wordMenu_Click(ByVal sender As System。对象,ByVal e As System.EventArgs)处理wordMenu.Click
Dim pinfo As New ProcessStartInfo( WINWORD
Dim p As Process = System.Diagnostics.Process.Start(pinfo)
p.WaitForInputIdle()
SetParent(p.MainWindowHandle,Label1.Handle )

End Sub
End Class



'这个家伙解释了如何在标签下运行winword ..但它不是working ....或删除被调用的框架的任何方法

解决方案

引起我注意的第一件事是:应该是winword.exe而不是WINWORD 。运行Word并不是一个好主意。您会考虑使用Word自动化吗?或者是其他东西?好吧,你将运行这个应用程序,你打算用它做什么?用户可以在没有您帮助的情况下运行它。



-SA


已回答在其中 [ ^ ]。

I want to run ms word application in my program. I have call the exe but I want to run under a frame means I do not want to show the border.or any method to remove the frame or border of external exe. Here is sample code which I got but not working

Public Class Form1
    Inherits System.Windows.Forms.Form
    Declare Function ShowWindow Lib "user32" (ByVal hWnd As System.IntPtr, ByVal nCmdShow As Integer) As Boolean
    Private Const SW_MINIMIZE As Integer = 6
    Private Const SW_MAXIMIZE As Integer = 3
    Private Const SW_RESTORE As Integer = 9

    Declare Function SetParent Lib "user32" (ByVal hWndChild As System.IntPtr, ByVal hWndNewParent As System.IntPtr) As System.IntPtr
#Region " Windows Form Designer generated code "

 
    Private Sub wordMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wordMenu.Click
        Dim pinfo As New ProcessStartInfo("WINWORD")
        Dim p As Process = System.Diagnostics.Process.Start(pinfo)
        p.WaitForInputIdle()
        SetParent(p.MainWindowHandle, Label1.Handle)

    End Sub
End Class


'Here this fellow explain how to run winword under a label.. But it is not working.... or any method to remove frame of called exe

解决方案

First thing which caught my eye is: should be "winword.exe" instead of "WINWORD". And it's not a good idea, to run Word. Would you consider using Word automation instead? Or something else? Well, you will run this application, and what are you going to do with it? The user can run it without your help.

—SA


Answered here[^].


这篇关于在vb,net的窗口下运行外部程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆