查看: 1  |  回复: 0
  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

调用时可以修改名称。

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com