2016-10-07 13 views
0

this stackoverflow entryに関しては、この機能を実装する必要はありません。NSISを使用してレジストリ内のSharedSectionを変更するにはどうすればよいですか?

System\\CurrentControlSet\\Control\\Session Manager\\SubSystemswindows文字列パラメータSharedSection=1024,20480,768の値を変更する必要があります。 第3の値は、まで増加する必要があります。

基本WriteRegStrReadRegStrの機能ではこれを行うことができません。

+2

これらの値を変更するときは、本当に注意する必要があり、システムが起動しない場合があります。

は、私は両方のビットを行うハイブリッドになってしまいました。 – Anders

答えて

2

レジストリ関数は文字列操作を実行できません。文字列を操作する必要がある場合は、NSISに付属しているヘルパーマクロの一部を見たり、自分で書くことができます。入力を間違えた場合

!include LogicLib.nsh 
!include StrFunc.nsh 
${StrLoc} 

Section 

ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" "Windows" 

${StrLoc} $7 $0 "SharedSection=" ">" ; Find "SharedSection=" 
StrCpy $R1 $0 $7 ; Save the stuff before "SharedSection=" 
StrCpy $R2 $0 "" $7 
${StrLoc} $8 $R2 " " ">" ; Find the end of "SharedSection=#,#,#" by looking for a space 
${IfThen} $8 = 0 ${|} StrLen $8 $R2 ${|} 
StrCpy $R3 $R2 "" $8 ; Save the stuff after "SharedSection=#,#,#" 
StrCpy $R2 $0 $8 $7 ; Save "SharedSection=#,#,#" 
; We can now parse "SharedSection=#,#,#": 
StrLen $8 $R2 
findcomma: 
    IntOp $8 $8 - 1 
    StrCpy $1 $R2 1 $8 
    StrCmp $1 "," findcomma_end 
    StrCmp $1 "" findcomma_end findcomma 
findcomma_end: 
IntOp $9 $8 + 1 
StrCpy $2 $R2 "" $9 
${If} $1 != "" ; Only edit if we found the comma.. 
${AndIf} $2 != "" ; ..And there was something after the comma 
    StrCpy $R2 $R2 $8 ; Copy the first part of the string 
    StrCpy $R2 "$R2,1536" ; Append the final comma and number 
${EndIf} 
StrCpy $0 "$R1$R2$R3" ; Build the final string 

DetailPrint Result=$0 
# TODO: WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" "Windows" $0 

SectionEnd 
関連する問題