当前位置 - 股票行情交易網 - 金融財經 - 如何讓VB運行我所指定的程序?

如何讓VB運行我所指定的程序?

有壹個函數:WinExec

聲明:

Private Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

---------------------------

lpCmdLine 保存程序的絕對路徑。

nCmdShow 保存程序的啟動方式。

啟動方式參數:

sw_hide:隱藏窗口

sw_maximze:最大化窗口

sw_minimze:最小化窗口

sw_restore:使用原始大小及位置顯示窗口,並進入活動狀態

sw_show:使用當前大小及位置顯示,並進入活動狀態

sw_showmaximized:最大化,激活

sw_showminimized:最小化,激活

sw_showminnoactive:最小化壹個窗口,並不改變活動窗口

sw_showna:使用當前大小及位置顯示,不改變活動窗口

sw_shownoactive:用最近的大小及位置顯示,不改變活動窗口

sw_shownormal:與sw_restore相同

'定義常量

Private Const sw_hide = 0

Private Const sw_maximze = 3

Private Const sw_minimze = 6

Private Const sw_restore = 9

Private Const sw_show = 5

Private Const sw_showmaximized = 3

Private Const sw_showminimized = 2

Private Const sw_showminnoactive = 7

Private Const sw_showna = 8

Private Const sw_shownoactive = 4

Private Const sw_shownormal = 1

'定義常量

程序過程(假設Command1的單擊事件)

Private Sub Command1_Click()

Call WinExec( Label1.Caption , SW_RESTORE)

End Sub

================================================

如果妳想用shell打開妳指向的文件則需要將Label1.Caption作為shell的參數整合到lpCmdLine中

比如:

Dim GoRun As string

GoRun = "shell地址" & " " & Label1.Caption

Call WinExce(GoRun,SW_RESTORE)

++++++++++++++++++++++++++++++++++

我對妳所說的shell方法並不很理解,不知道能不能幫上妳。