home *** CD-ROM | disk | FTP | other *** search
/ Freelog 117 / FreelogNo117-OctobreNovembre2013.iso / Theme / 8GadgetPack / 8GadgetPackSetup.msi / Gadgets.7z / Gadgets / Volume_Control.gadget / libhelper.js < prev    next >
Text File  |  2012-08-18  |  6KB  |  145 lines

  1. /////////////////////////////////////////////////////////////////////////////////////
  2. //                                                                                 //
  3. //  Libhelper 1.0 for .Net ActiveX Objects by Orbmu2k ⌐ 2007                       //
  4. //                                                                                 //
  5. //  Based on the some code of "Network Utilization" Gadget by Jonathan Abbott      //
  6. //  Many thanks to Jonathan Abbott this way :)                                     //
  7. //                                                                                 //
  8. //  Copyright ⌐ 2007 Orbmu2k.  All rights reserved.                                //
  9. //                                                                                 //
  10. //  http://blog.orbmu2k.de                                                         //
  11. //                                                                                 //
  12. //  Email: sidebargadget@orbmu2k.de                                                //
  13. //                                                                                 //
  14. /////////////////////////////////////////////////////////////////////////////////////
  15.  
  16. // ################## CONFIGURATION ###################
  17. var dllCLSID = "{71B1723C-1EC2-4b4d-868E-FA58C7F95CD9}";
  18. var Classname = "SoundControl.SoundControlGadget";
  19. var LibPath = "file:///" + System.Gadget.path.replace(new RegExp("\\\\", "g"), "/") + "/SoundControl.dll"
  20. var LibName = "SoundControl";
  21. // ####################################################
  22.  
  23. // Gloabal Vars
  24. var oShell = new ActiveXObject("WScript.Shell");
  25. var regRoot;
  26.  
  27. // is debugging ?
  28. var dbg = new ActiveXObject("Scripting.FileSystemObject");
  29. var bDebug = dbg.FileExists(System.Gadget.path+"\\debug.txt");
  30.  
  31. // Debuglog
  32. function debugLog(str) 
  33. {
  34.     try
  35.     {
  36.         if (bDebug)
  37.         {
  38.             var oFSO = new ActiveXObject("Scripting.FileSystemObject");
  39.             var iFlag = 2;
  40.             if (str != "")
  41.                 iFlag = 8; 
  42.         
  43.             var debugLogFile = oFSO.OpenTextFile(System.Gadget.path+"\\debug.txt", iFlag);
  44.             debugLogFile.WriteLine(new Date().toLocaleString() + ": " + str);
  45.             debugLogFile.Close();
  46.             debugLogFile = null;
  47.         }
  48.     } 
  49.     catch(err) 
  50.     {
  51.     }
  52. }
  53.  
  54. // Register ActiveX component
  55. function RegisterLibrary() 
  56. {
  57.     debugLog("RegisterLibrary:" + Classname);
  58.     var classRoot = regRoot + "\\Software\\Classes\\"+Classname+"\\";
  59.     var clsidRoot = regRoot + "\\Software\\Classes\\CLSID\\" + dllCLSID + "\\";
  60.  
  61.     try
  62.     {
  63.         oShell.RegWrite(classRoot,Classname, "REG_SZ");
  64.         oShell.RegWrite(classRoot + "CLSID\\", dllCLSID, "REG_SZ");
  65.         oShell.RegWrite(clsidRoot, Classname, "REG_SZ");
  66.         oShell.RegWrite(clsidRoot + "InprocServer32\\", "mscoree.dll", "REG_SZ");
  67.         oShell.RegWrite(clsidRoot + "InprocServer32\\ThreadingModel", "Both", "REG_SZ");
  68.         oShell.RegWrite(clsidRoot + "InprocServer32\\Class", Classname, "REG_SZ");
  69.         oShell.RegWrite(clsidRoot + "InprocServer32\\Assembly", LibName + ", Version=1.0.2588.9125, Culture=neutral, PublicKeyToken=null", "REG_SZ");
  70.         oShell.RegWrite(clsidRoot + "InprocServer32\\RuntimeVersion", "v4.0.30319", "REG_SZ");
  71.         oShell.RegWrite(clsidRoot + "InprocServer32\\CodeBase", LibPath , "REG_SZ");
  72.         oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\Class", Classname, "REG_SZ");
  73.         oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\Assembly", LibName + ", Version=1.0.2588.9125, Culture=neutral, PublicKeyToken=null", "REG_SZ");
  74.         oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\RuntimeVersion", "v4.0.30319", "REG_SZ");
  75.         oShell.RegWrite(clsidRoot + "InprocServer32\\1.0.2588.9125\\CodeBase", LibPath , "REG_SZ");
  76.         oShell.RegWrite(clsidRoot + "ProgId\\", Classname , "REG_SZ");
  77.         oShell.RegWrite(clsidRoot + "ProgId\\Implemented Categories\\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}\\", "", "REG_SZ");
  78.     }
  79.     catch(err) 
  80.     {
  81.         debugLog("RegisterLibrary: "+err.name+" - "+err.message)
  82.     }
  83. }
  84.  
  85. // Unregister ActiveX component
  86. function UnregisterLibrary() 
  87. {
  88.     debugLog("UnregisterLibrary:" + Classname);
  89.     var classRoot = regRoot + "\\Software\\Classes\\"+Classname+"\\";
  90.     var clsidRoot = regRoot + "\\Software\\Classes\\CLSID\\" + dllCLSID + "\\";
  91.  
  92.     try
  93.     {        
  94.         oShell.RegDelete(clsidRoot + "ProgId\\Implemented Categories\\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}\\");
  95.         oShell.RegDelete(clsidRoot + "ProgId\\Implemented Categories\\");
  96.         oShell.RegDelete(clsidRoot + "ProgId\\");
  97.         oShell.RegDelete(clsidRoot + "InprocServer32\\1.0.2588.9125\\");
  98.         oShell.RegDelete(clsidRoot + "InprocServer32\\");
  99.         oShell.RegDelete(clsidRoot);
  100.         oShell.RegDelete(classRoot + "CLSID\\");
  101.         oShell.RegDelete(classRoot);
  102.     }
  103.     catch(err) 
  104.     {
  105.         debugLog("UnregisterLibrary: "+err.name+" - "+err.message);
  106.     }
  107. }
  108.  
  109. // Try to Register the Library
  110. function ActivateLibrary(root) 
  111. {
  112.     debugLog("ActivateLibrary:" + root);
  113.     regRoot = root;
  114.     try
  115.     {
  116.         
  117.         RegisterLibrary();
  118.         debugLog("ReturnLibrary");
  119.         return new ActiveXObject(Classname);
  120.     }
  121.     catch(err)
  122.     {
  123.         debugLog("ActivateLibrary: "+err.name+" - "+err.message);
  124.         UnregisterLibrary();
  125.         return null;
  126.     }
  127. }
  128.  
  129. function GetLibrary()
  130. {
  131.     debugLog("Register ActiveX");
  132.     var Lib;
  133.     
  134.     // If UAC enabled registering to HKCU
  135.     Lib = ActivateLibrary("HKCU");
  136.     
  137.     // If UAC disabled registering to HKLM
  138.     if (Lib == null)
  139.         Lib = ActivateLibrary("HKLM");
  140.     
  141.     if (Lib == null)
  142.         debugLog("Error creating ActiveX object");
  143.     else
  144.         return Lib;
  145. }