ccartier
2nd November 2007 16:58 UTC
loop on file name
Hi
Suppose I have a folder full of DLLs I'd like to register.
At the moment, I use
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "name1.dll" "$LIBDIR\name1.dll" "$TEMP"
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "name2.dll" "$LIBDIR\name2.dll" "$TEMP"
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "name3.dll" "$LIBDIR\name3.dll" "$TEMP"
...
which is rather uggly.
Isn't it a simple way to loop on the folder content, ie all dll in the current folder ?
I'd appreciate any comments
Cheers
Cyril
[edit > JonnyMac] Moved from Winamp Tech Support to NSIS Discussion [/edit]
Afrow UK
2nd November 2007 20:36 UTC
You'd need to use this:
http://nsis.sourceforge.net/Invoking...n_compile-time
With that you can loop through all the dll files and generate the NSIS code with something like ${Locate} (FileFunc.nsh).
Stu
ccartier
5th November 2007 10:43 UTC
Thanks for the tip, I'll try your way.
But there remains a puzzle for me:
If the name of the DLL is hardcoded, as in the following command, it works fine,
!define LIBDIR "C:\mylibs"
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "name1.dll" "$LIBDIR\name1.dll" "$TEMP"
Why can I no longer compile if I use a variable, e.g.:
!define LIBDIR "C:\mylibs"
StrCpy $0 "name1.dll"
!insertmacro InstallLib REGDLL NOTSHARED NOREBOOT_NOTPROTECTED "$0" "$LIBDIR\$0" "$TEMP"
I get the following:
!insermacro: InstallLib
!error: InstallLib: The library $0 could not be found
So: is $0 not replaced by "name1.dll" at compile time ?
Cyril
Afrow UK
5th November 2007 10:51 UTC
Variables are for run time use only. StrCpy is a run time instruction. Also if you !define LIBDIR, the constant is ${LIBDIR} not $LIBDIR. $LIBDIR would be correct if it were a variable.
Stu
ccartier
5th November 2007 10:56 UTC
Ok! I know understand why I could not loop on the *.dll file in my folder.
Many thanks for your quick and precise answer
Cyril
Afrow UK
5th November 2007 11:41 UTC
Yep that is why you need to invoke outside code (or in the method I gave, to use a pre-built NSIS executable).
Stu