NSIS:为​​什么文本框值中的“文本”变为数字?

时间:2015-05-07 04:17:05

标签: textbox nsis mui

我已经创建了一个自定义页面(.nsh),并且有3个文本框(url, user, password)供用户输入,.NSI文件将这些数据写入属性文件。< / p>

但那些文字变成了数字9502966, 4718976 and 8455398. 我该怎么办?

这是我的示例代码:

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

结果#configure.properties

addi_url=18940788
addi_user=6750598
addi_password=11469950

但它应该是:

addi_url=usl.localhost
addi_user=username
addi_password=password

谢谢,

2 个答案:

答案 0 :(得分:0)

我猜你正在编写文件的控件句柄,但由于你的示例代码不好而无法知道。

应该看起来像这样:

void destroy_array(int** arr)
{
  free(arr[0]);
  free(arr);
}

答案 1 :(得分:0)

首先,您需要变量来存储控件的HWND。你还需要一个&#34;离开&#34;自定义页面的功能。当用户单击“下一步”按钮时,它将被执行。该函数必须读取文本控件。像这样:

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