Archive: FileRequest (Custom Page)


FileRequest (Custom Page)
Hy
I've already post this question but it was remove.

I post it again because I think, that iceman_k can help me.

You have help me with the Drop List (This was your Code):

!macro COPY_FILES SOURCE
CopyFiles /silent "$INSTDIR\Infos\Netsettings\${SOURCE}\netsettings.cfg" "$INSTDIR\cstrike\"
goto done
!macroend

; Copy Netsettings
Function CopyNetsettings

Push $R0
ReadINIStr $R0 "$PLUGINSDIR\netsettings.ini" "Field 1" "State"

StrCmp $R0 "LAN" 0 notLAN
!insertmacro COPY_FILES LAN
notLAN:

StrCmp $R0 "56K Modem" 0 not56K_Modem
!insertmacro COPY_FILES 56K_Modem
not56K_Modem:

done:
Pop $R0
FunctionEnd


At the moment I would like make an File Request with witch the user can choose an *.mp3

This Mp3 should me copy in the Folder $Installdir/valve/mp3

and the *.mp3 File must be renamed to 1.mp3.

The code which I write on the top is perhaps the same?

Could you show I you can help me... or the other user in this forum.

Thank you

p.s.

This is the CODE of my File Request.ini

[Settings]
NumFields=1

[Field 1]
Type=FileRequest
State=FileRequest
Filter=mp3
Left=2
Right=125
Top=6
Bottom=20

Here is the *.nsi for the File Request


The filter in your FileRequest box is incorrect. It should be [file description], then a pipe ("|") and then [filter].

Like this:
Filter=MP3 File|*.mp3

Next, you need a macro or function to copy the file. I'll show my example as a macro:


!macro CopyMP3 filename
push $0 ; used as temp
; The following line ensures that the directory exists.
; (no harm in calling it even if the directory exists.)
CreateDirectory '$INSTDIR\valve\mp3'
; use /SILENT in the following command to suppress the
; windows dialog if desired..
CopyFiles /FILESONLY '${filename}' '$INSTDIR\valve\mp3'
; now rename:
; if a file named '1.mp3' already exists, then delete it it
; no need to check ifexists--no errors returned if the file doesn't exist
delete /REBOOTOK '$INSTDIR\valve\mp3\1.mp3'
; Get the filename:
${GetFileName} '${filename}' $0
; now we can rename:
Rename /REBOOTOK '$INSTDIR\valve\mp3\$0' '$INSTDIR\valve\mp3\1.mp3'
pop $0
!macroend

In order to use the above, you have to use these 'rules':

1. you should use version 2.8 of NSIS. Otherwise, you'll have to download FileFunc from the Wiki.

2. You must call !include FileFunc.nsh and !insertmacro GetFileName at the top of your script.

3. ${filename} in the macro must be the full path/file name of the file the user selects.

4. you'll want to check for the reboot flag at the end of your script. (In case the user's file(s) are in use during the installation you'll be able to offer a reboot.)

Hy

thank you for your help. I know that I need a lot of help.. but what ist wrong with my code?


; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "File Request"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "FileFunc.nsh"

!insertmacro GetFileName

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

;Reserve File
ReserveFile "request.ini"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
;Custom page
Page custom RequestPage
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\File Request"
ShowInstDetails show
ShowUnInstDetails show

Section "Config & mehr" SEC01

Call CopyMP3

SectionEnd

Section -AdditionalIcons
SetOutPath $INSTDIR
CreateDirectory "$SMPROGRAMS\File Request"
CreateShortCut "$SMPROGRAMS\DFile Request\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\File Request\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
SectionEnd

; Funtions
Function .onInit

!insertmacro MUI_INSTALLOPTIONS_EXTRACT "request.ini"

FunctionEnd


!macro CopyMP3
push $0 ; used as temp
; The following line ensures that the directory exists.
; (no harm in calling it even if the directory exists.)
CreateDirectory '$INSTDIR\valve\mp3'
; use /SILENT in the following command to suppress the
; windows dialog if desired..
CopyFiles /SILENT /FILESONLY '${filename}' '$INSTDIR\valve\mp3'
; now rename:
; if a file named '1.mp3' already exists, then delete it it
; no need to check ifexists--no errors returned if the file doesn't exist
delete /REBOOTOK '$INSTDIR\valve\mp3\1.mp3'
; Get the filename:
${GetFileName} '${filename}' $0
; now we can rename:
Rename /REBOOTOK '$INSTDIR\valve\mp3\$0' '$INSTDIR\valve\mp3\1.mp3'
pop $0
!macroend


Function RequestPage

!insertmacro MUI_HEADER_TEXT "Konfiguration des Erweiterungs System" "Wählen Sie, eine MP3 Datei!"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "request.ini"

FunctionEnd

Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) wurde erfolgreich deinstalliert."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Möchten Sie $(^Name) und alle seinen Komponenten deinstallieren?" IDYES +2
Abort
FunctionEnd

Section Uninstall


DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd

Macros, unlike functions, can't be called--they must be inserted using the !insertmacro statement. Since they defined at compile time, it's a good idea to place them near the top of the script to ensure they'll be available to use later in the script.

My macro example uses a parameter (filename) to pass the information from your main script to the macro. This means that before you call the macro, you'll need to know the full path/file name of the file you need to copy.

For this reason, it should be placed either in a section or in the custompages leave function. An example might be something like this:


ReadIniStr $1 '$PLUGINSDIR\request.ini' 'Field 1' 'state'
!insertmacro CopyMP3 '$1'

Please keep in mind that my examples here should be viewed as just that--examples. (This is part of the reason I used so many comments throughout the script.) But in the end, it's up to you--the developer--to fit these to your own needs.

If you need more information about macros or functions, I suggest you read the documentation and look at some of the examples included with NSIS.

Hy thank you for your help.

I will try it. I hope that it works.


Perhaps if you would help me again you can write the code in my code that it works?

Thank you
Marc


mmh i'am don't understand what I must do but thank you for your help