The code is as follows:
JScript
Copy Code code as follows:
function Generateguid () {
var TypeLib = new ActiveXObject ("Scriptlet.Typelib");
return (TYPELIB.GUID);
}
VBScript
Copy Code code as follows:
Function Generateguid ()
Dim TypeLib
Set TypeLib = Server.CreateObject ("Scriptlet.Typelib")
Generateguid = Typelib.guid
End Function
If you want to use it on the client side, the code for VBScript needs to be slightly modified:
Set TypeLib = Server.CreateObject ("Scriptlet.Typelib")
Modified to:
Set TypeLib = CreateObject ("Scriptlet.Typelib")
However, when the client uses ActiveX, the IE default security setting prompts for the use of ActiveX, so it is not recommended.
If this is an ASP server, you can
ASP (using VBS)
Copy Code code as follows:
Function GUID ()
Dim Objtypelib
Set Objtypelib = CreateObject ("Scriptlet.Typelib")
GUID = Left (CStr (Objtypelib.guid), 38)
Set Objtypelib = Nothing
End Function
The code for ASP (using JScript) to create GUIDs on the server side is as follows:
Copy Code code as follows:
function GUID () {
return new ActiveXObject ("Scriptlet.Typelib"). Guid.tostring (). substring (0,38);
}