- 主题
- 0
- 积分
- 0
- 贝壳
- 0 个
- 注册时间
- 2006-11-29
- 最后登录
- 2006-11-29
|
求助一个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
|
|