所以基本上,我目前正在研究的一个项目是使用一个没有任何支持的旧游戏引擎,为了玩你需要注册一些dll。现在,引擎附带了一个RegisterFiles.exe,它将自动为您执行此操作,但问题是因为引擎太旧了,可执行文件对64位计算机不起作用(至少这就是我猜的)。
我正在寻找一个非常简单的可执行文件,它将注册3-4个dll / ocxs。我知道这是可能的,因为旧的RegisterFilex.exe程序使用32位操作系统。我在我的计算机上安装了Visual Studio,但我没有使用它。我是一个非常快速的学习者,所以我确信如果我朝着正确的方向努力,我最终会把它搞清楚!
感谢您提供的任何帮助!如果有一个更容易的选择而不是创建一个exe,我想听听这些建议!谢谢!
答案 0 :(得分:0)
我建议使用Process
Class启动regsvr32.exe并静默注册这些组件。
我认为它们是32位.dll
和/或.ocx
组件,因此此处使用\SysWOW64\regsvr32
。exe。由于regsvr32
是以/s
开关启动的,因此它不会显示任何信息对话框窗口。该过程本身无窗口启动并隐藏。
Public Class RegComponent
Public Path As String
Public IsRegistred As Boolean
End Class
Private RegComponentsList As List(Of RegComponent)
Public Sub RegisterComponents()
RegComponentsList = New List(Of RegComponent)
Dim RegSvr32 As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),
"SysWOW64", "regsvr32.exe")
RegComponentsList.Add(New RegComponent With {.Path = "[Component1Path]", .IsRegistred = False})
RegComponentsList.Add(New RegComponent With {.Path = "[Component2Path]", .IsRegistred = False})
RegComponentsList.Add(New RegComponent With {.Path = "[ComponentNPath]", .IsRegistred = False})
For Each RegComp As RegComponent In RegComponentsList
RegComp.IsRegistred = RegSvr32RegisterComponent(RegComp.Path, RegSvr32)
Next
End Sub
Public Function RegSvr32RegisterComponent(ByVal ComponentPath As String, RegSvr32Path As String) As Boolean
Dim ProcessExitCode As Boolean = False
Dim psInfo As ProcessStartInfo = New ProcessStartInfo
psInfo.CreateNoWindow = True
psInfo.UseShellExecute = False
psInfo.FileName = RegSvr32Path
psInfo.Arguments = "/s " + ComponentPath
psInfo.WindowStyle = ProcessWindowStyle.Hidden
Dim _Process As Process = New Process() With {.StartInfo = psInfo,
.EnableRaisingEvents = True,
.SynchronizingObject = Me}
_Process.Start()
'Add an event handler for the Exited event
AddHandler _Process.Exited,
Sub(source, e)
ProcessExitCode = (_Process.ExitCode = 0)
Console.WriteLine("This process has exited. Code: {0}", ProcessExitCode)
End Sub
_Process.WaitForExit()
_Process.Dispose()
Return ProcessExitCode
End Function