我有第三方EXE,我想嵌入简单的vb.net表单。 我尝试了很多种方法,但我无法完成。 这是我到目前为止所做的。 如果有人能帮助我..很感激! 谢谢 这是完整的来源。 它运作良好。 首先应该将EXE文件添加到项目的“资源”选项卡中 项目 - > property - >资源
Imports System.IO
Public Class Form1
' I am using a Button to call the Resources.Test file. You can edit it to fit your need.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Draq you EXE file to your Project > Resources and it will be saved as a RAW file.
Dim SetupPath As String = Application.StartupPath & "\project3.exe"
Using sCreateMSIFile As New FileStream(SetupPath, FileMode.Create)
sCreateMSIFile.Write(My.Resources.Project3, 0, My.Resources.Project3.Length)
End Using
Process.Start(SetupPath)
End Sub
Public Function MyProcessRunning(ByVal name As String) As Boolean
'Check if the process is runing. As ERROR handler.
For Each CloseMyProcess As Process In Process.GetProcesses()
If CloseMyProcess.ProcessName.StartsWith(name) Then
'process found running!!!
Return False
End If
Next
'process not found, So it is finaly been killed!!!
Return True
End Function
End Class
答案 0 :(得分:0)
尝试以下代码,并确保在项目中添加.exe作为参考
Public Class Form1
Private Sub Button1_Click(
ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim FileName As String = IO.Path.Combine(Application.StartupPath, "Filename.exe")
Dim BytesToWrite() As Byte = My.Resources.ColorCop
Dim FileStream As New System.IO.FileStream(FileName, System.IO.FileMode.OpenOrCreate)
Dim BinaryWriter As New System.IO.BinaryWriter(FileStream)
BinaryWriter.Write(BytesToWrite)
BinaryWriter.Close()
FileStream.Close()
Process.Start(FileName)
End Sub
End Class