//调用demo里面n_cst_dllTest所对应的js类
function DllTest(win) {
    var self = this;
    var nvo = null;
    this.Instance = null;
    this.ParentWindow = win;

    //obj是一个com对象实例,把obj保存到js类的私有变量nvo
    //然后通过nvo就可以调用不可视对象Invoke方式，从而调用相应的PB对象的实例方法
    this.Attach = function (obj) {
        nvo = obj;
        self.Instance = obj;
    }

    //对象释放
    this.Detach = function () {
        nvo = null;
        self.Instance = null;
    }

    //以下是调用n_cst_dllTest里面的具体函数
    this.GetSystemDir = function () {
        return nvo.Invoke("of_getsystemdirectory", "S");
    }

    this.GetWindowDir = function () {
        return nvo.Invoke("of_getwindowsdirectory", "S");
    }

    this.GetComputeName = function () {
        return nvo.Invoke("of_getcomputername", "S");
     
    }

    this.RunCalc = function () {
        //函数没有返回值,不需要return
        nvo.Invoke("of_runcalc", "Q");
    }
    this.RunNotePad = function () {
        //函数没有返回值,不需要return
        nvo.Invoke("of_runnotepad", "Q");
    }

    //直接调用声明的外部dll函数
    this.Add = function (num1, num2) {
        return nvo.Invoke("f_add", "LII", num1, num2);
    }

    //直接调用声明的外部dll函数
    this.Max = function (num1, num2) {
        return nvo.Invoke("f_max", "LII", num1, num2);
    }
    
}

//调用n_cst_Demo里面的功能
function NvoTest(win) {
    var self = this;
    var nvo = null;
    this.Instance = null;
    this.ParentWindow = win;

    //obj是一个com对象实例,把obj保存到js类的私有变量nvo
    //然后通过nvo就可以调用不可视对象Invoke方式，从而调用相应的PB对象的实例方法
    this.Attach = function (obj) {
        nvo = obj;
        self.Instance = obj;
    }

    //对象释放
    this.Detach = function () {
        nvo = null;
        self.Instance = null;
    }

    //参数dt传入的是一个Date类型的数据
    this.FormatDate = function (dt, fmt) {
        return nvo.Invoke("of_formatdate", "SWS", dt.getVarDate(), fmt);
    }

    //传入窗口名称，打开一个窗口
    this.OpenWindow = function (winName, dw) {

        //如果只传入一个参数，则表示只有窗口名称，没有需要向窗口传入的参数
        if (arguments.length == 1) {

            nvo.Invoke("of_openwin", "QS", winName);
        }
        else {
            //注册，传入的是数据窗口控件的COM指针，而不是js实例对象
            nvo.Invoke("of_openwin", "QSCu_dw_base.", winName, dw.Instance);
        }
    }
    this.InsertRow = function (row) {
        return nvo.Invoke("of_insertrow", "LL", row);
    }
    this.DeleteRow = function (row) {
        return nvo.Invoke("of_deleterow", "LL", row);
    }
    this.SetButtonText = function (name, text) {
        nvo.Invoke("of_setbuttontext", "QSS", name, text);
    }
    this.MyData = function () {
        return nvo.Invoke("f_get_regedit_font", "S");
    }
}

//调用UO_COMMON里面的功能
function CommonTest(win) {
    
    var self = this;
    var commonTest = null;
    this.Instance = null;
    this.ParentWindow = win;

    //obj是一个com对象实例,把obj保存到js类的私有变量nvo
    //然后通过nvo就可以调用不可视对象Invoke方式，从而调用相应的PB对象的实例方法
    this.Attach = function (obj) {
      
        commonTest = obj;
        self.Instance = obj;
    }

    //对象释放
    this.Detach = function () {
        commonTest = null;
        self.Instance = null;
    } 

    this.GetRegeditValues = function () {
 
        return commonTest.Invoke("f_get_regedit_font", "S");
    }  
    this.GetRegeditValues2 = function () {
 
        return commonTest.Invoke("f_get_compute_sn", "S");
    }
    // 获取Dll中客户端电脑的唯一ID
    this.GetMachineKey = function () {
        return commonTest.Invoke("f_get_machine_id", "S");
    }


//   //机器名
//LPCTSTR GetComputer(); 

    this.GetComputer = function () {
        return commonTest.Invoke("f_get_getcomputer", "S");
    } 
////IP地址
//DECLDIR LPCTSTR GetIPAddress();  
    this.GetIPAddress = function () {
        return commonTest.Invoke("f_get_getipaddress", "S");
    }
////OS主版本号
//DWORD GetOSMajorVersion();
    this.GetOSMajorVersion = function () {
                                  
        return commonTest.Invoke("f_get_getosmajorversion", "I");
    }
////OS次版本号
//DWORD GetOSMinorVersion();
    this.GetOSMinorVersion = function () {
        return commonTest.Invoke("f_get_getosminorversion", "I");
    }
////OS Build号
//DWORD GetOSBuildNumber();
    this.GetOSBuildNumber = function () {
        return commonTest.Invoke("f_get_getosbuildnumber", "I");
    }
////OS平台ID
//DWORD GetOSPlatformId();
    this.GetOSPlatformId = function () {
        return commonTest.Invoke("f_get_getosplatformId", "I");
    }
////处理器架构/OEM ID
//DWORD GetSystemOemId();
    this.GetSystemOemId = function () {
        return commonTest.Invoke("f_get_getsystemoemId", "I");
    }
////CPU激活掩码
//DWORD GetActiveProcessorMask();
    this.GetActiveProcessorMask = function () {
        return commonTest.Invoke("f_get_getactiveprocessormask", "I");
    }
////逻辑CPU数
//DWORD GetNumberOfProcessors();
    this.GetNumberOfProcessors = function () {
        return commonTest.Invoke("f_get_getnumberofprocessors", "I");
    }
////处理器类型
//DWORD GetProcessorType();
    this.GetProcessorType = function () {
        return commonTest.Invoke("f_get_getprocessortype", "I");
    }
////Windows主目录
//LPCTSTR GetWindowsPath();
    this.GetWindowsPath = function () {
        return commonTest.Invoke("f_get_getwindowspath", "S");
    }
////Windows主目录所在卷的序列号
//DWORD GetVolumeSerialNumber();
    this.GetVolumeSerialNumber = function () {
        return commonTest.Invoke("f_get_getvolumeserialnumber", "I");
    }



    // 获取Dll中客户端电脑的唯一ID
    this.A8erpPlayScanYes = function () {
        return commonTest.Invoke("f_play_music_yes", "Q");
    }
    // 获取Dll中客户端电脑的唯一ID
    this.A8erpPlayScanNo = function () {
        return commonTest.Invoke("f_play_music_no", "Q");
    }  
     // 人脸付
    this.A8erpRunExeFacePay = function (payJsonInfo) {
        return commonTest.Invoke("f_get_run_exe2", "QS", payJsonInfo);
    }    
    // RunExe
    this.A8erpRunExe = function (payJsonInfo) {
        return commonTest.Invoke("f_get_run_exe", "QS", payJsonInfo);
    }  
    // 获取INI的值通过Key 【人脸付】
    this.A8erpGetIniValueByKey = function (key) {
        return commonTest.Invoke("f_get_ini_value", "SS", key);
    }
    // SetINI的值通过Key 【人脸付】
    this.A8erpSetIniValueByKey = function (key,value) {
        return commonTest.Invoke("f_set_ini_value", "SSS", key, value);
    }
    // 获取INI的值通过Key 自定义路径
    this.A8erpGetIniValueByKeyAndPath = function (path,key1,key2) {
        return commonTest.Invoke("f_get_ini_value_path", "SSSS", path, key1, key2);
    } 
    // 设置INI的值通过Key 自定义路径
    this.A8erpSetIniValueByKeyAndPath = function (path,key1,key2,key3) {
        return commonTest.Invoke("f_set_ini_value_path", "SSSSS", path, key1, key2, key3);
    }
    //   【收银台拍照设备KEY】
    this.A8erpGetPosTakePhotoSerialNumByKey = function (url,key) {
        return commonTest.Invoke("f_get_pos_takephoto_key", "SSS", url, key);
    }
     //   【获取PB插件根目录】
    this.A8erpGetPbBaseDirectory = function () {
        return commonTest.Invoke("f_get_basedirectory", "S");
    }

    //   【读取 芯片IC卡】
    this.A8erpGetIckByRf = function () {
        var curKh = commonTest.Invoke("f_read_ic", "S");
        if (curKh.length >= 6) {
            curKh = curKh.substring(0,6);
        }
        return curKh;
    }
}

//调用n_cst_httpClient_Test里面的功能
function HttpClientTest(win) {
    var self = this;
    var nvo = null;
    this.Instance = null;
    this.ParentWindow = win;

    //obj是一个com对象实例,把obj保存到js类的私有变量nvo
    //然后通过nvo就可以调用不可视对象Invoke方式，从而调用相应的PB对象的实例方法
    this.Attach = function (obj) {
        nvo = obj;
        self.Instance = obj;
    }

    //对象释放
    this.Detach = function () {
        nvo = null;
        self.Instance = null;
    }

    this.PostData = function (url, data, type) {
        return nvo.Invoke("of_postdata", "SSSS", url, data, type);
    }
    this.GetData = function (url) {
        return nvo.Invoke("of_getdata", "SS", url);
    }
}