1、怎么实现开发系统的窗口功能。例如:txt框里输入“c:\winnt”,使用程序打开这个目录窗口
2、怎么实现点击一个任意文件,就可以把文件打开(当然文件和关联的程序一块打开,没有关联的可以告诉没有关联程序)可以直接留言解决方法这里或者发邮件给我[email protected]

解决方案 »

  1.   

    1
    Option ExplicitPrivate 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 LongPrivate Sub Command1_Click()
        ShellExecute Me.hwnd, vbNullString, txtPath.Text, vbNullString, vbNullString, 1
    End Sub
      

  2.   

    只要用API函数ShellExcute就可以搞定了
    首先声明
    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
    然后在Form1上放一个TextBox和一个CommandButton,在Command1的Click事件中写如下代码
    dim lngRet as long
    lngRet = ShellExecute(Me.hwnd, "open", text1.text, vbNullString, vbNullString, 5)
    if lngret = 31 then
        msgbox "没有关联程序"
    end if
      

  3.   

    使用 ShellExecute API 都可以解决了
      

  4.   

    Option ExplicitPrivate 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 SE_ERR_NOASSOC = 31Private Sub Command1_Click()
        Dim iRet As Long
        iRet = ShellExecute(Me.hwnd, "", txt.Text, "", "", vbNormalFocus)
        If iRet = SE_ERR_NOASSOC Then
            MsgBox "该文件没有相关联程序"
        End If
    End Sub
      

  5.   

    返回值的解释如下:
    0 The operating system is out of memory or resources. 
    ERROR_FILE_NOT_FOUND The specified file was not found. 
    ERROR_PATH_NOT_FOUND The specified path was not found. 
    ERROR_BAD_FORMAT The .exe file is invalid (non-Win32® .exe or error in .exe image). 
    SE_ERR_ACCESSDENIED The operating system denied access to the specified file.  
    SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid. 
    SE_ERR_DDEBUSY The DDE transaction could not be completed because other DDE transactions were being processed. 
    SE_ERR_DDEFAIL The DDE transaction failed. 
    SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out. 
    SE_ERR_DLLNOTFOUND The specified dynamic-link library was not found.  
    SE_ERR_FNF The specified file was not found.  
    SE_ERR_NOASSOC There is no application associated with the given file name extension. 
    SE_ERR_OOM There was not enough memory to complete the operation. 
    SE_ERR_PNF The specified path was not found. 
    SE_ERR_SHARE A sharing violation occurred.