fork download
  1. #cs ----------------------------------------------------------------------------
  2. Copyright 2009: Daniel Quadros de Miranda (aka danielkza)
  3.  
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://w...content-available-to-author-only...u.org/licenses/>.
  16.  
  17. AutoIt Version: 3.3.0.0
  18. Author: danielkza
  19.  
  20. Script Function:
  21. Properly register CDDB DLLs for portable Winamp Installations.
  22.  
  23. #ce ----------------------------------------------------------------------------
  24. #include <Array.au3>
  25. #include <File.au3>
  26.  
  27. Global $aNameList, $aPathList
  28. $iPathListOK = GetDLLList($aNameList, $aPathList, "(?i)CDDB.+NSWinamp\.[^\.]+(?!\.1)$")
  29.  
  30. IF NOT $iPathListOK Then
  31. $aNameList = _FileListToArray(@WorkingDir & "\plugins\gracenote", "*.dll", 1)
  32. Else
  33. For $i=1 To $aPathList[0]
  34. RunWait(StringFormat('regsvr32 /s /u "%s"', $aPathList[$i]))
  35. Next
  36. EndIF
  37.  
  38. For $i=1 To $aNameList[0]
  39. RunWait(StringFormat('regsvr32 /s "%s"', @WorkingDir & "\plugins\gracenote\" & $aNameList[$i]))
  40. Next
  41.  
  42. RunWait(@WorkingDir & "\winamp.exe")
  43.  
  44. For $i=1 To $aNameList[0]
  45. RunWait(StringFormat('regsvr32 /s /u "%s"', @WorkingDir & "\plugins\gracenote\" & $aNameList[$i]))
  46. Next
  47.  
  48. IF $iPathListOK Then
  49. For $i=1 To $aPathList[0]
  50. RunWait(StringFormat('regsvr32 /s "%s"', $aPathList[$i]))
  51. Next
  52. EndIf
  53.  
  54.  
  55. ; Backup Original DLL Paths
  56. Func GetDLLList(ByRef $aNameList, ByRef $aPathList, $szRegEx)
  57. Local $iEnumPos = 1, $szTempKey, $szGUID, $szDLLPath, $aDLLName, $iTempBound
  58. Local $aOrigDLLNames[33] = [0], $aOrigDLLPaths[33] = [0]
  59.  
  60. While True
  61. ; Enumerate key
  62. $szTempKey = RegEnumKey("HKCR", $iEnumPos)
  63. If @error Then ExitLoop
  64. $iEnumPos+=1
  65.  
  66. ; Check if it's one of the CDDB keys
  67. ; Keys are repeated. The second instances end with an '.1', and these will be ignored.
  68. If NOT StringRegExp($szTempKey, $szRegEx) Then ContinueLoop
  69.  
  70. ; Read the DLL GUID
  71. $szGUID = RegRead("HKCR\" & $szTempKey & "\CLSID", "")
  72. If @error Then ContinueLoop
  73.  
  74. ; Read the DLL path from the GUID key
  75. $szDLLPath = RegRead("HKCR\CLSID\" & $szGuid & "\InProcServer32", "")
  76. If @error Then
  77. $szDLLPath = RegRead("HKCR\WOW6432Node\CLSID\" & $szTempKey & "\InProcServer32", "")
  78. If @error Then ContinueLoop
  79. EndIf
  80. If NOT FileExists($szDLLPath) Then ContinueLoop
  81.  
  82. ; Get the filename from the full path
  83. $aDLLName = StringRegExp($szDLLPath, "([^\\/]+)(?![\\/])$", 1)
  84. If NOt IsArray($aDLLName) Then ContinueLoop
  85. $szDLLName = $aDLLName[0]
  86.  
  87. ; Check if we don't have this DLL already
  88. $iTempBound = UBound($aOrigDLLNames)
  89.  
  90. If _ArraySearch($aOrigDLLNames, $szDLLName, 1, $iTempBound) <> -1 Then
  91. ContinueLoop
  92. EndIf
  93.  
  94. ; Array is filled already, enlarge it
  95. If $aOrigDLLNames[0] == $iTempBound-1 Then
  96. ReDim $aOrigDLLNames[$iTempBound + 32]
  97. ReDim $aOrigDLLPaths[$iTempBound + 32]
  98. EndIf
  99.  
  100. $aOrigDLLNames[0] += 1
  101. $aOrigDLLPaths[0] += 1
  102.  
  103. $aOrigDLLNames[$aOrigDLLNames[0]] = $szDLLName
  104. $aOrigDLLPaths[$aOrigDLLPaths[0]] = $szDLLPath
  105. WEnd
  106.  
  107. If $aOrigDLLNames[0] Then
  108. $aNameList = $aOrigDLLNames
  109. $aPathList = $aOrigDLLPaths
  110.  
  111. Return SetError(0, $aOrigDLLNames[0], 1)
  112. EndIf
  113.  
  114. Return SetError(1, 0, 0)
  115. EndFunc
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty