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 = [];
if(typeof(objectName) == "object") {
objectNames = objectName;
exports.CreateObject = function(progId, serverName) {
var progIds = [];
var _CreateObject = function(p, s) {
if (typeof(WScript) !== "undefined") {
return WScript.CreateObject(p, s);
} 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 {
return new ActiveXObject(objectNames[i]);
return _CreateObject(progIds[i], serverName);
} catch(e) {};
}
};