-1

I've created a custom page(.nsh) and there are 3 text boxes (url, user, password) for user typing in it and .NSI file will get these data to write into a properties file.

But those text became to numeric such 9502966, 4718976 and 8455398. What should I do?

This is my example code:

AcustomPage.nsh

...

!macro create_AcustomPage APP_NAME CUS_URL CUS_USER CUS_PWD
Page custom create_AcustomPage
Function create_AcustomPage
   ...
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_URL}"
   Pop $AcustomPage.url
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_USER}"
   Pop $AcustomPage.user
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_PWD}"
   Pop $AcustomPage.pwd
   ...
FunctionEnd
...
!macroend

Project.nsi

...

 !insertmacro create_AcustomPage "${NAME} ${VERSION}-${RELEASE}" "url.localhost" "username" "password"
...    
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_url=" "$CUS_URL" $R0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_user=" "$CUS_USER" $R0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_password=" "$CUS_PWD" $R0

Result #configure.properties

addi_url=18940788
addi_user=6750598
addi_password=11469950

But it should be:

addi_url=usl.localhost
addi_user=username
addi_password=password

Thanks,

Machavity
  • 30,841
  • 27
  • 92
  • 100
Chill Gal
  • 15
  • 5

2 Answers2

0

I'm guessing you are writing the controls handle to the file but it is impossible to know because of your poor example code.

It should probably look something like this:

InstallDir "$Temp\Test"

!include TextFunc.nsh
!include nsDialogs.nsh


var hCtlUrl
var hCtlUsr
var hCtlPwd

!define DefaultUrl "url.localhost"
!define DefaultUsr "foo"
!define DefaultPwd "bar"

Function mypageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateText} 60u 30u 60% 11u "${DefaultUrl}"
Pop $hCtlUrl
${NSD_CreateText} 60u 50u 60% 11u "${DefaultUsr}"
Pop $hCtlUsr
${NSD_CreateText} 60u 70u 60% 11u "${DefaultPwd}"
Pop $hCtlPwd
nsDialogs::Show
FunctionEnd

Function mypageLeave
${NSD_GetText} $hCtlUrl $0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_url=" "$0" $R0
${NSD_GetText} $hCtlUsr $0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_user=" "$0" $R0
${NSD_GetText} $hCtlPwd $0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_password=" "$0" $R0
FunctionEnd

Page Directory
Page InstFiles
Page Custom mypageCreate mypageLeave
Anders
  • 97,548
  • 12
  • 110
  • 164
0

First, you need variables to store control's HWND. You also need a "leave" function for your custom page. It'll be executed when user clicks on Next button. That function has to read the text controls. Something like this:

Var customer_url
Var customer_user
Var customer_password

Page custom create_AcustomPage leave_AcustomPage

Function create_AcustomPage
   ...
   ${NSD_CreateText} 60u 50u 60% 11u "Type your url..."
   Pop $0
   ${NSD_CreateText} 60u 50u 60% 11u "Type your username..."
   Pop $1
   ${NSD_CreateText} 60u 50u 60% 11u "Type your password..."
   Pop $2
   ...
FunctionEnd

Function leave_AcustomPage
  # Read form
  ${NSD_GetText} $0 $customer_url
  ${NSD_GetText} $1 $customer_user
  ${NSD_GetText} $2 $customer_password

  # save form to config file
  ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_url=" "$customer_url" $R0
  ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_user=" "$customer_user" $R0
  ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_password=" "$customer_password" $R0
FunctionEnd
Francisco R
  • 4,032
  • 1
  • 22
  • 37