2016-09-19 2 views
-1

Je suis nouveau pour nsis Créé ini page qui contient le type "Texte", en utilisant ce type je montrais les données dynamiques certaines dans l'étiquette. La taille du fichier est de 2 Ko, je dois donc augmenter la taille de l'option "State" dans le type "Text". Alors, comment augmenter la taille de l'Etat en utilisant writeinistr?Augmenter la taille du tampon pour "Writeinistr" dans nsis

+0

Le label Le contrôle n'utilise pas le champ Etat. – Anders

+0

Erreur de typo pas d'étiquette c'est un texte – karthik

Répondre

0

Pour contourner la limitation de longueur de la chaîne NSIS vous devez appeler l'API Windows directement:

Page Custom MyPage 
Page InstFiles 

!macro IniWriteAsciiStringPtr ini sec name strptr 
!if "${NSIS_CHAR_SIZE}" > 1 
Push $0 
Push $1 
Push $2 
Push "${ini}" 
Push "${name}" 
Push "${sec}" 
StrCpy $0 ${strptr} 
System::Call 'kernel32::MultiByteToWideChar(i0, i0, i$0, i-1, i0, i0)i.r2' 
System::Call '*(&w$2)i.r1' 
System::Call 'kernel32::MultiByteToWideChar(i0, i0, i$0, i-1, ir1, ir2)' 
System::Call 'kernel32::WritePrivateProfileString(t s, t s, ir1, t s)' 
System::Free $1 
Pop $2 
Pop $1 
Pop $0 
!else 
System::Call 'kernel32::WritePrivateProfileString(t "${sec}", t "${name}", i ${strptr}, t "${ini}")' 
!endif 
!macroend 

!include InstallOptions.nsh 
Function MyPage 
InitPluginsDir 
; Building the entire .ini at run-time in this example 
WriteIniStr "$PluginsDir\io.ini" Settings NumFields 1 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Type Text 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Left 1 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Right -2 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Top 5 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Bottom -10 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Flags MULTILINE 
FileOpen $0 "$PluginsDir\test.txt" r 
FileSeek $0 0 END $1 
FileSeek $0 0 SET 
System::Call '*(&i$1,i0)i.r2' 
System::Call 'kernel32::ReadFile(ir0,ir2,ir1,*i,i0)' 
!insertmacro IniWriteAsciiStringPtr "$PluginsDir\io.ini" "Field 1" "State" $2 
System::Free $2 
FileClose $0 

!insertmacro INSTALLOPTIONS_DISPLAY "io.ini" 
FunctionEnd 

Function .onInit 
InitPluginsDir 
; Create a big file for this example 
FileOpen $0 "$PluginsDir\test.txt" w 
StrCpy $2 0 
loop: 
    StrCmp $2 2048 done 
    IntOp $1 $2 % 10 
    StrCmp $2 2047 0 +2 
    StrCpy $1 "!" 
    FileWrite $0 $1 
    IntOp $2 $2 + 1 
    Goto loop 
done: 
FileClose $0 
FunctionEnd 

Vous pouvez également contourner le .ini et le mettre directement dans la boîte de dialogue:

Page Custom MyPage 
Page InstFiles 

!include InstallOptions.nsh 
!include WinMessages.nsh 
Function MyPage 
InitPluginsDir 
; Building the entire .ini at run-time in this example 
WriteIniStr "$PluginsDir\io.ini" Settings NumFields 1 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Type Text 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Left 1 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Right -2 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Top 5 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Bottom -10 
WriteIniStr "$PluginsDir\io.ini" "Field 1" Flags MULTILINE 
FileOpen $0 "$PluginsDir\test.txt" r 
FileSeek $0 0 END $1 
FileSeek $0 0 SET 
System::Call '*(&i$1,i0)i.r2' 
System::Call 'kernel32::ReadFile(ir0,ir2,ir1,*i,i0)' 
FileClose $0 
!insertmacro INSTALLOPTIONS_INITDIALOG "io.ini" 
Pop $0 
!insertmacro INSTALLOPTIONS_READ $0 "io.ini" "Field 1" "HWND" 
!if "${NSIS_CHAR_SIZE}" > 1 
!error TODO 
!else 
SendMessage $0 ${WM_SETTEXT} 0 $2 
!endif 
System::Free $2 
!insertmacro INSTALLOPTIONS_SHOW 
FunctionEnd 

Function .onInit 
InitPluginsDir 
; Create a big file for this example 
FileOpen $0 "$PluginsDir\test.txt" w 
StrCpy $2 0 
loop: 
    StrCmp $2 2048 done 
    IntOp $1 $2 % 10 
    StrCmp $2 2047 0 +2 
    StrCpy $1 "!" 
    FileWrite $0 $1 
    IntOp $2 $2 + 1 
    Goto loop 
done: 
FileClose $0 
FunctionEnd