zoukankan      html  css  js  c++  java
  • win7,xp通用的打开文件浏览对话框的方法

    第一种:
    Function BrowseForFile() 
        Dim shell : Set shell = CreateObject("WScript.Shell") 
        Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") 
        Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2) 
        Dim tempName : tempName = fso.GetTempName() 
        Dim tempFile : Set tempFile = tempFolder.CreateTextFile(tempName & ".hta") 
        tempFile.Write _ 
        "<html>""<head>""<title>Browse</title>""</head>" & _ 
        "<body>" & _ 
        "<input type='file' id='f' />" & _ 
        "<script type='text/javascript'>" & _ 
        "var f = document.getElementById('f');" & _ 
        "f.click();" & _ 
        "var shell = new ActiveXObject('WScript.Shell');" & _ 
        "shell.RegWrite('HKEY_CURRENT_USER\Volatile Environment\MsgResp', f.value);" & _ 
        "window.close();" & _ 
        "</script>" & _ 
        "</body>" & _ 
        "</html>"
        tempFile.Close 
        shell.Run tempFolder & "" & tempName & ".hta", 0, True
        BrowseForFile = shell.RegRead("HKEY_CURRENT_USERVolatile EnvironmentMsgResp") 
        shell.RegDelete "HKEY_CURRENT_USERVolatile EnvironmentMsgResp"
    EndFunction
    MsgBox BrowseForFile() 


    第二种:
    dim oShell  
    set oShell = CreateObject("Shell.Application")  
    oShell.MinimizeAll ' 最小化所有窗口
    oShell.FindFiles ' 打开文件搜索窗口
    oShell.Explore "F:"' i浏览文件夹
    oShell.BrowseForFolder 0,"请为程序选择一个文件夹",0x1000|0x0001,0x0000

    第三种:
    Set oIE = CreateObject("InternetExplorer.Application")
    oIE.Navigate "About:Blank"
    oIE.Document.Write "<INPUT TYPE='file' ID='x' />"
    Set oElement = oIE.Document.getElementById("x")
    oElement.Click
    WScript.Echo oElement.Value
    oIE.Quit

  • 相关阅读:
    write(byte[] b, int off, int len)
    getAttribute 与getParmeter 区别
    ServletContext
    SercletConfig 详解
    MYSQL导入数据出现ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
    mybatis在xml文件中处理大于号小于号的方法
    阿里云实名认证接口调试
    js encodeuricomponent base64
    Introspector内存溢出的原理解析
    JVM虚拟机工作原理
  • 原文地址:https://www.cnblogs.com/futrueface/p/4123387.html
Copyright © 2011-2022 走看看