Archive: loop on file name


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]


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


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


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


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


Yep that is why you need to invoke outside code (or in the method I gave, to use a pre-built NSIS executable).

Stu