写了一个类似开始菜单运行的TEXT窗口。但是不能加载.msc命令。请各位帮我一下。代码如下。Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim SS As String
SS = Text1.Text
strPath = Environ("SystemRoot") & "\system32\"
Shell strPath & SS, 1
End If
End Sub
我想在输入*.msc命令的时候,(就是开始菜单里运行可以执行的那些.msc命令)。执行以下代码:
strPath = Environ("SystemRoot") & "\system32\"
Shell strPath & "MMC.EXE " & strPath & SS,vbNormalFocus
问题是我不会写如何判断输入的内容是不是.msc结尾的。请会的不惜赐教。
还有网上找了一个可以直接调用开始菜单里运行的代码。可是出来却是韩文。我想可以调用中文的。请大家帮下。
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 Sub Command1_Click() 
SHRunDialog hWnd, 0, 0, "运行", "点击 确定 运行输入的程序", -chkRunNoMRU 
End Sub 

解决方案 »

  1.   

    "问题是我不会写如何判断输入的内容是不是.msc结尾的"
    是指判断text1.text的后4位?那不就是right(s,4)=".msc"吗?
      

  2.   

    SHRunDialog 乱码问题参考:http://topic.csdn.net/t/20010730/21/216195.html运行.msc可以使用shellexecute
      

  3.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    Dim SS, ID As String
    SS = Text1.Text
    ID = Right(SS, 4)
    Select Case ID
        Case ".msc"
            strPath = Environ("SystemRoot") & "\system32\"
            Shell strPath & "MMC.EXE " & strPath & SS, vbNormalFocus
        Case Else
            strPath = Environ("SystemRoot") & "\system32\"
            Shell strPath & SS, 1
    End Select
    End If
    End Sub
    写好了。谢谢了!
      

  4.   

    3楼给的SHRunDialog 乱码问题参考:http://topic.csdn.net/t/20010730/21/216195.html
    我去看了。依旧是乱码。