home *** CD-ROM | disk | FTP | other *** search
/ Freelog 117 / FreelogNo117-OctobreNovembre2013.iso / Theme / 8GadgetPack / 8GadgetPackSetup.msi / Gadgets.7z / Gadgets / Network_Meter_V8.4.gadget / libhelper.js < prev    next >
Text File  |  2010-07-15  |  3KB  |  64 lines

  1. var dllCLSID  = "{25815CC0-43F4-3C75-8C3A-A139D9ADE740}";
  2. var Classname = "NICGadget.NetworkInformation";
  3. var LibPath   = "file:///" + System.Gadget.path.replace(new RegExp("\\\\", "g"), "/") + "/netlib.dll"
  4. var LibName   = "NetLib";
  5. var oShell    = new ActiveXObject("WScript.Shell");
  6. var regRoot;
  7.  
  8. function RegisterLibrary(){
  9.  var classRoot = regRoot + "\\Software\\Classes\\" + Classname+"\\";
  10.  var clsidRoot = regRoot + "\\Software\\Classes\\CLSID\\" + dllCLSID + "\\";
  11.  try{
  12.   oShell.RegWrite(classRoot,Classname,"REG_SZ");
  13.   oShell.RegWrite(classRoot + "CLSID\\",dllCLSID,"REG_SZ");
  14.   oShell.RegWrite(clsidRoot,Classname,"REG_SZ");
  15.   oShell.RegWrite(clsidRoot + "InprocServer32\\","mscoree.dll", "REG_SZ");
  16.   oShell.RegWrite(clsidRoot + "InprocServer32\\ThreadingModel", "Both", "REG_SZ");
  17.   oShell.RegWrite(clsidRoot + "InprocServer32\\Class", Classname, "REG_SZ");
  18.   oShell.RegWrite(clsidRoot + "InprocServer32\\Assembly", LibName + ", Version=1.0.2588.9125, Culture=neutral, PublicKeyToken=null", "REG_SZ");
  19.   oShell.RegWrite(clsidRoot + "InprocServer32\\RuntimeVersion", "v2.0.50727", "REG_SZ");
  20.   oShell.RegWrite(clsidRoot + "InprocServer32\\CodeBase", LibPath , "REG_SZ");
  21.   oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\Class", Classname, "REG_SZ");
  22.   oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\Assembly", LibName + ", Version=1.0.2588.9125, Culture=neutral, PublicKeyToken=null", "REG_SZ");
  23.   oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\RuntimeVersion", "v2.0.50727", "REG_SZ");
  24.   oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\CodeBase", LibPath , "REG_SZ");
  25.   oShell.RegWrite(clsidRoot + "ProgId\\",Classname ,"REG_SZ");
  26.   oShell.RegWrite(clsidRoot + "ProgId\\Implemented Categories\\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}\\", "", "REG_SZ");
  27.  }
  28.  catch(err){return null;}
  29. }
  30.  
  31. function UnregisterLibrary(){
  32.  var classRoot = regRoot + "\\Software\\Classes\\"+Classname+"\\";
  33.  var clsidRoot = regRoot + "\\Software\\Classes\\CLSID\\" + dllCLSID + "\\";
  34.  try{        
  35.   oShell.RegDelete(clsidRoot + "ProgId\\Implemented Categories\\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}\\");
  36.   oShell.RegDelete(clsidRoot + "ProgId\\Implemented Categories\\");
  37.   oShell.RegDelete(clsidRoot + "ProgId\\");
  38.   oShell.RegDelete(clsidRoot + "InprocServer32\\1.0.2588.9125\\");
  39.   oShell.RegDelete(clsidRoot + "InprocServer32\\");
  40.   oShell.RegDelete(clsidRoot);
  41.   oShell.RegDelete(classRoot + "CLSID\\");
  42.   oShell.RegDelete(classRoot);
  43.  }
  44. catch(err) {}
  45. }
  46.  
  47. function ActivateLibrary(root){
  48.  regRoot=root;
  49.  try{
  50.   RegisterLibrary();
  51.   return new ActiveXObject(Classname);
  52.  }
  53.  catch(err){
  54.   UnregisterLibrary();
  55.   return null;
  56.  }
  57. }
  58.  
  59. function GetLibrary(){
  60.  var Lib;
  61.  Lib = ActivateLibrary("HKCU");
  62.  if (Lib == null) Lib = ActivateLibrary("HKLM");
  63.  return Lib;
  64. }