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") { if (typeof(CreateObject) !== "function") {
var CreateObject = function(className) { var CreateObject = function(progId, serverName) {
return new ActiveXObject(className); 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 // Emulate Server.CreateObject
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
exports.CreateObject = function(objectName) { exports.CreateObject = function(progId, serverName) {
var objectNames = []; var progIds = [];
var _CreateObject = function(p, s) {
if(typeof(objectName) == "object") { if (typeof(WScript) !== "undefined") {
objectNames = objectName; return WScript.CreateObject(p, s);
} else { } else {
objectNames.push(objectName); return new ActiveXObject(p, s);
}
};
if (typeof(progId) == "object") {
progIds = progId;
} else {
progIds.push(progId);
} }
for (var i = 0; i < objectNames.length; i++) { for (var i = 0; i < progIds.length; i++) {
try { try {
return new ActiveXObject(objectNames[i]); return _CreateObject(progIds[i], serverName);
} catch(e) {}; } catch(e) {};
} }
}; };