Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 1st September 2010, 12:01   #1
TheGrudge
Junior Member
 
Join Date: Jul 2010
Posts: 9
Find dll files in all directories listed in the PATH variable

I need to find a DLL in a list of directories, e.g. in the PATH variable.

PATH = "c:\aaaa;c:\bbbb" etc

I have written a method that reads the registry and splits the string with a STRTOK method I found in the NSIS wiki:

code:
Function readPathVar
ReadRegStr $0 HKLM "${REG_ENVIRONMENT}" "Path"
Push $0
StrCpy $1 $0
${While} $0 != ""
Push ";"
Call StrTok
Pop $0
${If} $0 == ""
FindFirst $2 $3 $0\some.dll
FindClose $2
${If} $3 != ""
${NSD_CB_AddString} $ComboBox "$1"
${EndIf}
${Else}
FindFirst $2 $3 $0\some.dll
FindClose $2
${If} $3 != ""
${NSD_CB_AddString} $ComboBox "$0"
${EndIf}
${EndIf}
Pop $1
Push $1
${EndWhile}
FunctionEnd



I works for all items but the last one, so the path "c:\bbbb" is never searched for the dll.
Also it doesn't work if the PATH looks like this:

PATH = "c:\aaaa;;c:\bbbb" etc

The duplicate ';' character will not deliver all tokens in the string.
Isn't there an easy way to split a string in NSIS?
Or is there a plugin that can find a file in a list of directories?
TheGrudge is offline   Reply With Quote
Old 1st September 2010, 12:48   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
From the NSIS Users Manual:
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.2
pengyou is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump