VB中怎么设置ErrorLevel

来源:百度知道 编辑:UC知道 时间:2024/07/02 18:44:07
我一个程序退出需要设置ErrorLevel,我想知道怎么在程序中设置ErrorLevel。然后再DOS下可以查看到这个ErrorLevel。听说好像也是ExitCode

模块中声明:
Public Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

窗体代码:
Private Sub Command1_Click()

' TerminateProcess -1, 1125 'also can
ExitProcess 1234

End Sub

测试程序:

模块声明:
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, uExitCode As Long) As Long

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Public Declare Function CloseHandle Lib