fix CreateObject

This commit is contained in:
Namhyeon Go 2020-10-20 14:18:00 +09:00
parent a62837ed25
commit 90d45137aa
2 changed files with 36 additions and 10 deletions

23
app.js
View File

@ -69,8 +69,27 @@ var console = {
};
if (typeof(CreateObject) !== "function") {
var CreateObject = function(className) {
return new ActiveXObject(className);
var CreateObject = function(progId, serverName) {
var progIds = [];
var _CreateObject = function(p, s) {
if (typeof(WScript) !== "undefined") {
return WScript.CreateObject(p, s);
} else {
return new ActiveXObject(p, s);
}
};
if (typeof(progId) == "object") {
progIds = progId;
} else {
progIds.push(progId);
}
for (var i = 0; i < progIds.length; i++) {
try {
return _CreateObject(progIds[i], serverName);
} catch (e) {};
}
};
}

View File

@ -76,18 +76,25 @@ exports.require = global.require;
// Emulate Server.CreateObject
/////////////////////////////////////////////////////////////////////////////////
exports.CreateObject = function(objectName) {
var objectNames = [];
exports.CreateObject = function(progId, serverName) {
var progIds = [];
var _CreateObject = function(p, s) {
if (typeof(WScript) !== "undefined") {
return WScript.CreateObject(p, s);
} else {
return new ActiveXObject(p, s);
}
};
if(typeof(objectName) == "object") {
objectNames = objectName;
if (typeof(progId) == "object") {
progIds = progId;
} else {
objectNames.push(objectName);
progIds.push(progId);
}
for (var i = 0; i < objectNames.length; i++) {
try {
return new ActiveXObject(objectNames[i]);
for (var i = 0; i < progIds.length; i++) {
try {
return _CreateObject(progIds[i], serverName);
} catch(e) {};
}
};