返回列表 发帖

求助一个VB,谁都可以~~

[这个贴子最后由黑色叶子在 2005/07/06 09:44pm 第 1 次编辑]

ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOW = 5

这段代码没错吧?(放在通用里面)
但点启动后显示shell32.dll缺少结束语?`````
我的目的是做个连接工具,比如点按键连接到E:/NC/NC.exe
第一次写,还搞得乱七八糟*(^%^*~~~~指教 指教~~

求助一个VB,谁都可以~~

这是我自己做的一个仿运行的程序源代码: Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Const SW_NORMAL = 1 Private Const SW_MAXIMIZE = 3 Private Const SW_MINIMIZE = 6 Private Const SW_SHOW = 5 Private Sub Command1_Click() Dim lR As Long Dim sFile As String Dim iFile As Integer '; 创建一个测试用的文本文件 sFile = App.Path & "\TEST.TXT" On Error Resume Next Kill sFile On Error GoTo 0 iFile = FreeFile Open sFile For Binary Access Write As #iFile Put #iFile, , "这是一个测试文件,演示ShellExecute API函数。" Close #iFile '; 依照文件名打开这个文本。Windows将会检查哪个可执行程序与.TXT关联 '; (默认一般是Notepad),并运行程序打开文档 lR = ShellExecute(Me.hWnd, "Open", sFile, "", "", vbNormalFocus) If (lR < 0) Or (lR > 32) Then '; 成功 Else MsgBox "无法打开 ';" & sFile & "';", vbInformation End If End Sub Private Sub Command2_Click() filepath = Text1.Text lR = ShellExecute(Me.hWnd, "Open", filepath, "", "", vbNormalFocus) End Sub Private Sub Command3_Click() CD1.ShowOpen Text1.Text = CD1.FileName End Sub Private Sub Command4_Click() End End Sub Private Sub Form_Load() Command2.Enabled = False End Sub Private Sub Text1_Change() If Text1.Text <> "" Then Command2.Enabled = True Else Command2.Enabled = True End If End Sub

TOP

求助一个VB,谁都可以~~

用Shell吧,更加简单实用,不用API,一句Shell搞定!
打开文件:
  Shell "rundll32.exe url.dll,FileProtocolHandler "路径"

TOP

返回列表 回复 发帖