Old 4th December 2015, 15:18   #1
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,007
Send a message via Skype™ to thinktink
Expand special shell folder id in path

So I need to make a smarter plugin install script that programmatically finds the proper plugins and languages folder for the current Winamp install as these settings can be changed by the user. I've looked at the paths.ini file and found only one entry: "inidir={26}\Winamp"

At first this entry was confusing, but then I checked shlobj.h and found that the number 26 is the flag to use in the call to SHGetSpecialFolderLocation(...) to retrieve the current user's %APPDATA% folder. This is good as it leads to the current user's winamp.ini file which then can be queried to locate all the directories for plugins and language files.

So my question is, is there a built-in function that I'm just plain not seeing to automatically expand that inidir field?
thinktink is offline   Reply With Quote
Old 4th December 2015, 16:09   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,122
PHP Code:
!include LogicLib.nsh
Section SimpleHack
/*Emulate ReadIniStr:*/ StrCpy $"{26}\Winamp" ;ReadIniStr $... inidir
StrCpy 
$$0 4
${If} $== "{26}"
    
StrCpy $$"" 4
    StrCpy 
$"$AppData$0"
${EndIf}
DetailPrint $0
SectionEnd  

Section Proper
/*Emulate ReadIniStr:*/ StrCpy $"{26}\Winamp" ;ReadIniStr $... inidir
StrCpy 
$$0 1
${If} $== "{"
    
StrCpy $1 0
    loop
:
        
IntOp $$1
        StrCpy 
$$0 1 $1
        StrCmp 
$"" notspecial Reached end of string without finding }
        
StrCmp $"}" 0 loop
        IntOp 
$$1
        StrCmp 
$1 0 notspecial Ignore "{}"
        
StrCpy $$$1 1
        System
::Call 'SHELL32::SHGetFolderPath(i0, ir2, i0, i0, t.r2)' Win2000+,  more operations required for 95/98/NT4
        IntOp 
$$2
        StrCpy 
$$"" $1
        StrCpy 
$"$2$1"
    
notspecial:
${EndIf}
DetailPrint $0
SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th December 2015, 16:22   #3
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,007
Send a message via Skype™ to thinktink
Thanks.
thinktink is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
expand, folder, shell

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