Old 7th February 2008, 11:57   #1
Vino87
Junior Member
 
Join Date: Feb 2008
Posts: 6
Help with Locate function

Hi,

Im making an installer for a mod right now and i need to be able to search for a directory on the users PC and set that directory as the Installation Directory. Is there any way I could use the Locate function to do this
Vino87 is offline   Reply With Quote
Old 7th February 2008, 14:33   #2
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
if you want the user to select a directory,
look for "Page directory" in NSIS Help File
or !insertmacro MUI_PAGE_DIRECTORY in MUI ReadMe file

if you want to search for a specific existing directory, you will need to tell us more about what you want
Wizou is offline   Reply With Quote
Old 7th February 2008, 14:37   #3
Vino87
Junior Member
 
Join Date: Feb 2008
Posts: 6
I dont want the user to select it, i wanna search the users computer for a certain directory and if it exist install there, if not, quit the installation. The game must be installed for the mod to be installed
Vino87 is offline   Reply With Quote
Old 7th February 2008, 14:43   #4
Wizou
Senior Member
 
Join Date: Aug 2007
Location: Paris, France
Posts: 304
usually the best thing is to get the directory from the registry, under the "Uninstall" key for example
Wizou is offline   Reply With Quote
Old 7th February 2008, 15:24   #5
fabian.rap.more
Senior Member
 
Join Date: Dec 2007
Posts: 111
Send a message via Yahoo to fabian.rap.more
if its a game then there should be a registry key pointing to the folder where its installed.............if u dont know where the key is located the snnop around the registry or google it

What some invent the rest enlarge
fabian.rap.more is offline   Reply With Quote
Old 8th February 2008, 06:32   #6
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
@ Vino87,
following example will search in all available HDDs for a given directory,
code:
outfile "test.exe"
ShowInstDetails Show

!include FileFunc.nsh
!insertmacro Locate
!insertmacro GetDrives

Section
${GetDrives} "HDD" "GetDrives_CallBack"
SetOutPath "$R0"
DetailPrint "$OUTDIR"
SectionEnd

Function GetDrives_CallBack
StrCpy $R1 "$9"
StrCmp "$R1" "$R2" +3
MessageBox MB_YESNO "Search in $R1 hard disk?" IDYES +2
goto end
${Locate} "$R1" "/L=D /M=CONTRIB" "Locate_CallBack"
StrCpy $R2 "$R1"
IfErrors 0 +2
MessageBox MB_OK "Error" IDOK +2
MessageBox MB_OK "$$R0=$R0"
end:
Push $0
FunctionEnd

Function Locate_CallBack
StrCpy $R0 $R9
MessageBox MB_YESNO '$R0$\n$\nFind next?' IDYES +2
StrCpy $0 StopLocate
Push $0
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 8th February 2008, 11:56   #7
Vino87
Junior Member
 
Join Date: Feb 2008
Posts: 6
Thanks
Vino87 is offline   Reply With Quote
Old 8th February 2008, 12:50   #8
fabian.rap.more
Senior Member
 
Join Date: Dec 2007
Posts: 111
Send a message via Yahoo to fabian.rap.more
Red Wine's function is quite good but u should expect the user to change the name of the folder..........i admit that not many will but it will be safer to read the location from the registry............the game's official site should have a section like this

What some invent the rest enlarge
fabian.rap.more 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