mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 21:51:04 +00:00
fix CreateObject
This commit is contained in:
parent
a62837ed25
commit
90d45137aa
23
app.js
23
app.js
|
@ -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) {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
lib/std.js
23
lib/std.js
|
@ -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(WScript) !== "undefined") {
|
||||||
|
return WScript.CreateObject(p, s);
|
||||||
|
} else {
|
||||||
|
return new ActiveXObject(p, s);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(typeof(objectName) == "object") {
|
if (typeof(progId) == "object") {
|
||||||
objectNames = objectName;
|
progIds = progId;
|
||||||
} else {
|
} else {
|
||||||
objectNames.push(objectName);
|
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) {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user