Command()函数就是用来获取命令行参数的。如果你在命令行输入"ABC.exe AAAAA",该函数返回"AAAAA"。该函数返回的字符串是区分大小写的,如果你对命令行的处理是不区分大小写的, 别忘了使用Ucase或Lcase函数处理一下。为了方便在集成环境中调试,你可以在工程属性中的生成标签中设置命令行参数.
sub Main()
msgbox Command()
end sub
Private Sub GetCommandString()
Dim ExecCommand As String
Dim StartupIndex As Long
ExecCommand = UCase(Command()) '此行获得命令行参数
'读入Ini文件信息(此函数为自定义,调用API)
StartupIndex = ReadOneStringToLong("Option", "SelectIndex")
'当命令参数为
'/Console
If Not (InStr(ExecCommand, "/CONSOLE") = 0) Then StartupIndex = 0
'/Logo
If Not (InStr(ExecCommand, "/LOGO") = 0) Then StartupIndex = 5
'/QuickButton
If Not (InStr(ExecCommand, "/QUICKBUTTON") = 0) Then StartupIndex = 11
'/About
If Not (InStr(ExecCommand, "/ABOUT") = 0) Then StartupIndex = 15
End Sub