哪位高人 帮我 看一下 下面的VB.NET 转换成 VB6.0 问题在哪里 怎么读不到信息
Imports System
Imports System.Diagnostics
Imports System.IOPublic Class UpdaterHelper
' Methods
Public Shared Function CheckNewFiles() As Integer
Return UpdaterHelper.RunUpdater("-checkforupdates", True)
End Function Public Shared Sub RunUpdater()
UpdaterHelper.RunUpdater(String.Empty, False)
End Sub Private Shared Function RunUpdater(ByVal arguments As String, ByVal waitForExit As Boolean) As Integer
Dim fileInfo As New FileInfo(UpdaterHelper._updaterPath)
If Not fileInfo.Exists Then
Return 0
End If
Dim startInfo As New ProcessStartInfo
startInfo.FileName = fileInfo.FullName
startInfo.WorkingDirectory = fileInfo.Directory.FullName
startInfo.Arguments = arguments
Dim process As New Process
process.StartInfo = startInfo
If Not process.Start Then
End If
If Not waitForExit Then
Return 0
End If
process.WaitForExit()
Return process.ExitCode
End Function
' Fields
Private Shared _updaterPath As String = Path.Combine(Application.StartupPath, "qupdater.exe")
End Class一下是 VB 6.0
Option ExplicitPrivate Declare Function PathFileExists Lib "shlwapi" _
Alias "PathFileExistsA" _
(ByVal pszPath As String) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As LongPrivate Declare Function ShellExecuteEx Lib "shell32" _
Alias "ShellExecuteExA" _
(SEI As SHELLEXECUTEINFO) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long 'Optional
lpClass As String 'Optional
hkeyClass As Long 'Optional
dwHotKey As Long 'Optional
hIcon As Long 'Optional
hProcess As Long 'Optional
End TypePrivate Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Sub Form_Load()
Dim sFileName As String
'sFileName = App.Path & "\qupdater.exe"
sFileName = "qupdater.exe"
If PathFileExists(sFileName) Then
Call GetCheckForUpdates(sFileName, Me.hwnd)
End If
End SubPrivate Sub GetCheckForUpdates(sFileName As String, hWndOwner As Long)
Dim SEI As SHELLEXECUTEINFO
Dim hProcess As Long
Dim lResult As Long
Dim resp As Integer
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or _
SEE_MASK_FLAG_NO_UI
.hwnd = hWndOwner
.lpVerb = vbNullChar
.lpFile = sFileName
.lpParameters = "-checkforupdates"
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
hProcess = ShellExecuteEx(SEI)
Call WaitForSingleObject(hProcess, 120000)
lResult = 0
Call GetExitCodeProcess(hProcess, lResult)
If lResult > 0 Then
resp = MsgBox("found some new files at the website,now to upgrade?", vbYesNo)
If resp = vbYes Then
SEI.lpParameters = vbNull
hProcess = ShellExecuteEx(SEI)
End If
End If
End SubPrivate Function FileExists(ByVal sPath As String) As Boolean
FileExists = PathFileExists(sPath)
End Function
读取的是 qupdater.exe 的-checkforupdates参数 VB 读不到 ShellExecuteEx返回1
Imports System
Imports System.Diagnostics
Imports System.IOPublic Class UpdaterHelper
' Methods
Public Shared Function CheckNewFiles() As Integer
Return UpdaterHelper.RunUpdater("-checkforupdates", True)
End Function Public Shared Sub RunUpdater()
UpdaterHelper.RunUpdater(String.Empty, False)
End Sub Private Shared Function RunUpdater(ByVal arguments As String, ByVal waitForExit As Boolean) As Integer
Dim fileInfo As New FileInfo(UpdaterHelper._updaterPath)
If Not fileInfo.Exists Then
Return 0
End If
Dim startInfo As New ProcessStartInfo
startInfo.FileName = fileInfo.FullName
startInfo.WorkingDirectory = fileInfo.Directory.FullName
startInfo.Arguments = arguments
Dim process As New Process
process.StartInfo = startInfo
If Not process.Start Then
End If
If Not waitForExit Then
Return 0
End If
process.WaitForExit()
Return process.ExitCode
End Function
' Fields
Private Shared _updaterPath As String = Path.Combine(Application.StartupPath, "qupdater.exe")
End Class一下是 VB 6.0
Option ExplicitPrivate Declare Function PathFileExists Lib "shlwapi" _
Alias "PathFileExistsA" _
(ByVal pszPath As String) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As LongPrivate Declare Function ShellExecuteEx Lib "shell32" _
Alias "ShellExecuteExA" _
(SEI As SHELLEXECUTEINFO) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long 'Optional
lpClass As String 'Optional
hkeyClass As Long 'Optional
dwHotKey As Long 'Optional
hIcon As Long 'Optional
hProcess As Long 'Optional
End TypePrivate Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Sub Form_Load()
Dim sFileName As String
'sFileName = App.Path & "\qupdater.exe"
sFileName = "qupdater.exe"
If PathFileExists(sFileName) Then
Call GetCheckForUpdates(sFileName, Me.hwnd)
End If
End SubPrivate Sub GetCheckForUpdates(sFileName As String, hWndOwner As Long)
Dim SEI As SHELLEXECUTEINFO
Dim hProcess As Long
Dim lResult As Long
Dim resp As Integer
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or _
SEE_MASK_FLAG_NO_UI
.hwnd = hWndOwner
.lpVerb = vbNullChar
.lpFile = sFileName
.lpParameters = "-checkforupdates"
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
hProcess = ShellExecuteEx(SEI)
Call WaitForSingleObject(hProcess, 120000)
lResult = 0
Call GetExitCodeProcess(hProcess, lResult)
If lResult > 0 Then
resp = MsgBox("found some new files at the website,now to upgrade?", vbYesNo)
If resp = vbYes Then
SEI.lpParameters = vbNull
hProcess = ShellExecuteEx(SEI)
End If
End If
End SubPrivate Function FileExists(ByVal sPath As String) As Boolean
FileExists = PathFileExists(sPath)
End Function
读取的是 qupdater.exe 的-checkforupdates参数 VB 读不到 ShellExecuteEx返回1
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货