- NSIS Discussion
- Plugin for my application
Archive: Plugin for my application
Mosestycoon
31st May 2004 21:56 UTC
Plugin for my application
Dear Community -
I have a problem of creating a plugin for my main-application (MY-APP). In fact I don't know how to plug in.
The idea I had was to make MY-APP write a registry key to HKLM SOFTWARE\MY-APP with the value InstallPath with (guess what) the installation path of MY-APP (e.g. C:\Program Files\My-App)
So how can I use this value as new $INSTDIR for the plugin?
Thx in advance
Chris
Joost Verburg
1st June 2004 13:03 UTC
Use ReadRegStr and then set the folder using SetOutPath.
If you prefer to use the $INSTDIR variable use StrCpy and SetOutPath.
Mosestycoon
1st June 2004 19:35 UTC
Thx for your reply, I already gave it (a successful) try, but allow me one more question Joost. I did it like this
Function getInstallPath
ReadRegStr $R9 HKLM "SOFTWARE\MY-APP" "InstallPath"
StrCmp $R9 "" done
done:
FunctionEnd
Where do I have to paste a potential abortion if the main application isn't installed and is it possible to handle this "globaly", or do I have to call this function everytime I need it (e.g. section, uninstaller, etc.)?
Chris
Mosestycoon
1st June 2004 21:17 UTC
I try to write the abortion option mentioned above. Therefore I (tried to) analyize the waplugin example shipped with the NSIS package. I found the "IfFileExists" and now I want to know if there is something similar for registrykeys?
Chris
deguix
2nd June 2004 03:35 UTC
Yes. Everytime you call ReadRegStr it can return a value if it exists or set errors if it doesn't exist.
Mosestycoon
2nd June 2004 09:05 UTC
So can you please tell what I have to set and where I have to place it?
Right now the installation would be already impossible if the core package is not installed. But you get an *cancel - retry - ignore* messagebox because the installpath is invalid (it tries to install to a path starting with a '\' not C:\ or D:\).
Chris
deguix
2nd June 2004 10:54 UTC
Put it inside .onInstFailed callback function.
Mosestycoon
2nd June 2004 11:16 UTC
Sorry deguix, this makes no sense to me (! and only me !), so please help me out:
This callback is called when the user hits the 'cancel' button after the install has failed (if it could not extract a file, or the install script used the Abort command)
Would this trigger the installer to stop automatically from installing (or even not to enable the install button like in the waplugin example) if the registry key is not found?
Thx
Chris
deguix
2nd June 2004 12:07 UTC
Ahhhhh... The components page... I thought that was the installation part...
Ok, put that inside the callback function .onVerifyInstDir.
Mosestycoon
2nd June 2004 20:43 UTC
Hm, I gave it a try, but without the desired result. Any other ideas?
iceman_k
2nd June 2004 21:18 UTC
Why not just check for the registry value in the .onInit function and quit the installer with an error message if it is not present?
Slightly adapting the example from the NSIS documentation, you could use:
Function .onInit
ReadRegStr $INSTDIR HKLM "SOFTWARE\MY-APP" "Path"
StrCmp $INSTDIR "" 0 NoAbort
MessageBox MB_OK "MY-APP not found. Unable to get install path."
Abort ; causes installer to quit.
NoAbort:
FunctionEnd
Mosestycoon
2nd June 2004 22:21 UTC
Thx Iceman_K
That's it. It works.
Your my man :D