
Знатоки ! Внимание вопрос !
Как при запуске ВБ проги считать адрес файла => автоматически его открыть ?
Если тема была, то сорри, не нашёл... Тогда плиз, линк киньте...
Option Explicit
'функции Win32 API
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, _
ByVal ByteLen As Long)
Private Declare Function GetCommandLine Lib _
"kernel32" Alias "GetCommandLineA" () As Long
Private Declare Function lstrlen Lib "kernel32" Alias _
"lstrlenA" (ByVal lpString As Long) As Long
Private Sub Form_Load()
MsgBox GetFName(GetCommLine)
End Sub
Public Function GetFName(CommandStr As String) As String
On Error Resume Next
Dim rc As Long, rc2 As Long, rc3 As Long, rc4 As Long
rc = InStr(1, CommandStr, Chr(34))
If rc = 0 Then Exit Function
rc2 = InStr(rc + 1, CommandStr, Chr(34))
If rc2 = 0 Then Exit Function
rc3 = InStr(rc2 + 1, CommandStr, Chr(34))
If rc3 = 0 Then rc3 = rc2 + 1
rc4 = InStr(rc3 + 1, CommandStr, Chr(34))
If rc4 = 0 Then rc4 = Len(CommandStr) + 1
GetFName = Mid$(CommandStr, rc3 + 1, rc4 - rc3 - 1)
End Function
Private Function GetCommLine() As String
On Error Resume Next
Dim RetStr As Long, SLen As Long
RetStr = GetCommandLine
SLen = lstrlen(RetStr)
If SLen > 0 Then
GetCommLine = Space$(SLen)
CopyMemory ByVal GetCommLine, ByVal RetStr, SLen
End If
End Function
Private Sub Form_Load()
MsgBox Command$
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 21