Private Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As String VB声明不对,该函数返回应是字符串指针,应为 Private Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As Long, ByVal Length As Long)Private Sub Form_Load() Dim lRet As Long, sCmd As String lRet = GetCommandLine If lRet > 0 Then sCmd = String(256, 32) CopyMemory sCmd, lRet, Len(sCmd) sCmd = Mid(sCmd, 1, InStr(1, sCmd, Chr(0)) - 1) End If End Sub
VB声明不对,该函数返回应是字符串指针,应为
Private Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As Long, ByVal Length As Long)Private Sub Form_Load()
Dim lRet As Long, sCmd As String
lRet = GetCommandLine
If lRet > 0 Then
sCmd = String(256, 32)
CopyMemory sCmd, lRet, Len(sCmd)
sCmd = Mid(sCmd, 1, InStr(1, sCmd, Chr(0)) - 1)
End If
End Sub