Get Mozilla Plugin Path: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.)
(Added indentation to code.)
 
Line 11: Line 11:
|}
|}


This is a macro that looks through the HKLM\SOFTWARE\Mozilla registry to find the first entry with information on the plugin dir and put it on the top of the stack..
This is a macro that looks through the HKLM\SOFTWARE\Mozilla registry to find the first entry with information on the plugin dir and put it on the top of the stack.


== The Macro ==
== The Macro ==
Line 19: Line 19:
!macro MozillaPluginDir
!macro MozillaPluginDir


Push $R0
  Push $R0
Push $R1
  Push $R1
Push $R2
  Push $R2


!define Index 'Line${__LINE__}'
  !define Index 'Line${__LINE__}'
StrCpy $R1 "0"
  StrCpy $R1 "0"


"${Index}-Loop:"
  "${Index}-Loop:"


   ; Check for Key
   ; Check for Key
Line 35: Line 35:
   StrCmp $R2 "" "${Index}-Loop" "${Index}-End"
   StrCmp $R2 "" "${Index}-Loop" "${Index}-End"


"${Index}-End:"
  "${Index}-End:"


!undef Index
  !undef Index


Push $R2
  Push $R2
Exch 3
  Exch 3
Pop $R2
  Pop $R2
Pop $R1
  Pop $R1
Pop $R0
  Pop $R0


!macroend</highlight-nsis>
!macroend</highlight-nsis>
Line 52: Line 52:


Section ""
Section ""
  !insertmacro MozillaPluginDir
!insertmacro MozillaPluginDir
  Pop $R0
Pop $R0
  MessageBox MB_OK "$R0"
MessageBox MB_OK "$R0"
SectionEnd
SectionEnd
</highlight-nsis>
</highlight-nsis>


Got started with help from [http://nsis.sourceforge.net/archive/viewpage.php?pageid=307 Check for a Registry Key] by Vytautas
Got started with help from the page "[[Check for a Registry Key]]" by [[User:Vytautas|Vytautas]].


[[Category:Other Products Version Detection Functions]]
[[Category:Other Products Version Detection Functions]]

Latest revision as of 10:50, 16 October 2005

Author: Zunk (talk, contrib)


How To Use

Input: None
Output: String to the plugin dir, or empty

This is a macro that looks through the HKLM\SOFTWARE\Mozilla registry to find the first entry with information on the plugin dir and put it on the top of the stack.

The Macro

Save as mozillaplugin.nsh in NSIS\Include.

!macro MozillaPluginDir
 
  Push $R0
  Push $R1
  Push $R2
 
  !define Index 'Line${__LINE__}'
  StrCpy $R1 "0"
 
  "${Index}-Loop:"
 
  ; Check for Key
  EnumRegKey $R0 HKLM "SOFTWARE\Mozilla" "$R1"
  StrCmp $R0 "" "${Index}-End"
  IntOp $R1 $R1 + 1
  ReadRegStr $R2 HKLM "SOFTWARE\Mozilla\$R0\Extensions" "Plugins"
  StrCmp $R2 "" "${Index}-Loop" "${Index}-End"
 
  "${Index}-End:"
 
  !undef Index
 
  Push $R2
  Exch 3
  Pop $R2
  Pop $R1
  Pop $R0
 
!macroend

Example of usage

!include "mozillaplugin.nsh"
 
Section ""
  !insertmacro MozillaPluginDir
  Pop $R0
  MessageBox MB_OK "$R0"
SectionEnd

Got started with help from the page "Check for a Registry Key" by Vytautas.