首页 /编程语言和算法/VB6/ASP
 VB6 显示windows“运行”对话框
今天 19:22

新建From1(窗体),新建Command1(按钮CommandButton),代码:

'To display the "Run" dialog use the following routine:
Private Declare Function SHRunDialog Lib "shell32" Alias "#61" (ByVal hOwner As Long, ByVal Unknown1 As Long, ByVal Unknown2 As Long, ByVal szTitle As String, ByVal szPrompt As String, ByVal uFlags As Long) As Long
Private Declare Function GetActiveWindow Lib "user32" () As Long
'Purpose     :  Shows the run dialog
'Inputs      :  sTitle                  The title of the dialog
'               sDescription            The description text inside the dialog
'               bShowLastRun            If True displays the last Run in the combo else the combo is empty
'Outputs     :
'Notes       :  Modified from code found on www.allapi.net
'Revisions   :
'Assumptions :
Private Sub ShowRunDialog(Optional sTitle As String = "Start a program ...", Optional sDescription As String = "Type the name of a program ...", Optional bShowLastRun As Boolean = True)
    Const shrdNoMRUString As Long = &H2
    If bShowLastRun Then
        SHRunDialog GetActiveWindow, 0, 0, StrConv(sTitle, vbUnicode), StrConv(sDescription, vbUnicode), 0
    Else
        SHRunDialog GetActiveWindow, 0, 0, StrConv(sTitle, vbUnicode), StrConv(sDescription, vbUnicode), shrdNoMRUString
    End If
End Sub

Private Sub Command1_Click()
    Call ShowRunDialog
End Sub

调用时可以修改名称。

 
全部回复(0)
首页 | 电脑版 |