zoukankan      html  css  js  c++  java
  • ActiveXObject常用方法

    function getusername() {
        var WshNetwork = new ActiveXObject("WScript.Network");
        alert("Domain = " + WshNetwork.UserDomain);
        alert("Computer Name = " + WshNetwork.ComputerName);
        alert("User Name = " + WshNetwork.UserName);
    }
    取得机器名,登录域及登录用户名
    function getprocessnum() {
        var pnsys = new ActiveXObject("WScript.shell");
        pn = pnsys.Environment("PROCESS");
        alert(pn("WINDIR"));
    }
    取得系统目录
    function getspecialfolder() {
        var mygetfolder = new ActiveXObject("WScript.shell");
        if (mygetfolder.SpecialFolders("Fonts") != null) {
            alert(mygetfolder.SpecialFolders("Fonts"));
        }
    }
    返回系统中特殊目录的路径
    function getdiskinfo(para) {
        var fs = new ActiveXObject("scripting.filesystemobject");
        d = fs.GetDrive(para);
        s = "卷标:" + d.VolumnName;
        s += "------" + "剩余空间:" + d.FreeSpace / 1024 / 1024 + "M";
        s += "------" + "磁盘序列号:" + d.serialnumber;
        alert(s)
    }
    取得磁盘信息 传入参数如:getdiskinfo('c')
    function getprocessnum() {
        var pnsys = new ActiveXObject("WScript.shell");
        pn = pnsys.Environment("PROCESS");
        alert(pn("WINDIR"));
    }
    取得系统目录
    function runcalc() {
        var calc = new ActiveXObject("WScript.shell");
        calc.Run("calc");
    }
    启动计算器
    function readreg() {
        var myreadreg = new ActiveXObject("WScript.shell");
        try {
            alert(myreadreg.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\NeroCheck"));
        }
        catch (e) {
            alert("读取的值不存在!");
        }
    }
    读取注册表中的值
    function writereg() {
        var mywritereg = new ActiveXObject("WScript.shell");
        try {
            mywritereg.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\MyTest", "c:\mytest.exe");
            alert("写入成功!");
        }
        catch (e) {
            alert("写入路径不正确!");
        }
    }
    写注册表
    function delreg() {
        var mydelreg = new ActiveXObject("WScript.shell");
        if (confirm("是否真的删除?")) {
            try {
                mydelreg.RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\MyTest");
                alert("删除成功!");
            }
            catch (e) {
                alert("删除路径不正确");
            }
        }
    }
    删除注册表
    function getfileinfo(para) {
        var myfile = new ActiveXObject("scripting.filesystemobject");
        var fi = myfile.GetFile(para);
        alert("文件类型:" + fi.type + "文件大小:" + fi.size / 1024 / 1024 + "M" + "最后一次访问时间:" + fi.DateLastAccessed);
    }
    取得文件信息 调用方式如:getfileinfo('c:\test.pdf')
    function clientInfo() {
        strClientInfo = "availHeight=      " + window.screen.availHeight + "
    " +
    "availWidth=      " + window.screen.availWidth + "
    " +
    "bufferDepth=      " + window.screen.bufferDepth + "
    " +
    "colorDepth=      " + window.screen.colorDepth + "
    " +
    "colorEnable=      " + window.navigator.cookieEnabled + "
    " +
    "cpuClass=      " + window.navigator.cpuClass + "
    " +
    "height=      " + window.screen.height + "
    " +
    "javaEnable=      " + window.navigator.javaEnabled() + "
    " +
    "platform=      " + window.navigator.platform + "
    " +
    "systemLanguage=      " + window.navigator.systemLanguage + "
    " +
    "userLanguage=      " + window.navigator.userLanguage + "
    " +
    "width=      " + window.screen.width;
        alert(strClientInfo);
    }
    取得客户端的信息
    function saveas() {
        var ExcelApp = new ActiveXObject("Excel.Application");
        var ExcelSheet = new ActiveXObject("Excel.Sheet")
        ExcelSheet.Application.Visible = true;
        ExcelSheet.ActiveSheet.Cells(1, 1).Value = "This is column A, row 1";
        ExcelSheet.SaveAs("C:\TEST.XLS");
        ExcelSheet.Application.Quit();
        alert('ok');
    }
    另存为excel文件并写入值
  • 相关阅读:
    关于Spring和Struts2的整合
    有关Transaction not successfully started问题解决办法
    两种页面跳转
    jdbc连接mysql
    change和modify
    Navicat Premium 15连接Oracle时提示oracle library is not loaded的解决方案
    Oracle创建本地数据库实例及配置监听
    下载Visual Studio 2019离线安装包
    简单的数据库
    未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
  • 原文地址:https://www.cnblogs.com/vichin/p/11064023.html
Copyright © 2011-2022 走看看