'添加一个Microsoft Common Dialog Control 6.0部件
'添加一个CommandButton控件
'添加一个ListBox控件
'添加一个Label控件
'------------------------------------------------
'读写INI文件
Private Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function SaveINI Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As String, ByVal lplFileName As String) As Long
'读写INI文件
Function GetINI(AppName As String, KeyName As String, filename As String) As String
Dim RetStr As String
RetStr = String(10000, Chr(0))
GetINI = Left(RetStr, GetPrivateProfileString(AppName, ByVal KeyName, "", RetStr, Len(RetStr), filename))
'读:Rtn = GetINI(AppName, KeyName, filename)
'写:SaveINI appname,keyname,string,filename
End Function
Private Sub Command1_Click()
CommonDialog1.Filter = "所有文件(*.*)|*.*"
CommonDialog1.FilterIndex = 1
CommonDialog1.ShowOpen
List1.AddItem CommonDialog1.filename
End Sub
Private Sub Form_Load()
For i = 0 To Val(GetINI("listcount", "Count", App.Path & "\st.ini")) - 1
List1.AddItem GetINI("list", CStr(Format(i, "000")), App.Path & "\st.ini"), i
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 1 To List1.ListCount
SaveINI "list", CStr(Format(i - 1, "000")), List1.List(i - 1), App.Path & "\st.ini"
Next i
SaveINI "ListCount", "Count", List1.ListCount, App.Path & "\st.ini"
End Sub
Private Sub List1_Click()
Label1.Caption = List1.Text
End Sub
可以试试:
Shell
"app.exe
"
&
app.Path
&
"\文件.flv",
vbNormalFocus
友情提示:Shell在操作文件路径的时候,如果路径中或者文件名中包含空格,需要利用Chr(34)对路径进行在处理!!
测试不通过的话再留言!!
你可以将应用程序及需要的参数文件放在同一个目录下,这样你就是移动到别的电脑上也是一样可以执行的.
如:
...\app.exe
...\文件.flv
先取得参数文件的路径
Dim
curFile
as
string
curFile=App.Path
+
"\文件.flv"
...
curFile="app.exe
"+curFile
'转换为一字符串,注意
app.exe
后面的空格!
然后再执行你的
Shell
curFile,vbNormalFocus
sPath
=
"app.exe
c:\绝对路径\文件.flv"
If
Left(Mid(sPath,
10),
2)
=
":\"
Then
Shell
sPath
这样检测路径比较精确,检测.exe空格后2个字符,如果是":\"就会执行Shell语句