Search code examples
registryinno-setuppascalscript

Writing binary data to registry using Inno Setup Pascal Scripting


I need your help again please. I want write in registry with a hex entry. How can we do this? I need a function under [Code] section.

This is what I do:

procedure ADDRegistry;
begin
  RegWriteDWordValue(HKLM64,'SYSTEM\CurrentControlSet\services\FIDTPU\Parameters', 'CalibMode', 0);

  RegWriteBinaryValue(HKLM64,'SYSTEM\CurrentControlSet\services\FIDTPU\Parameters', 'Caldata9' + 
    #7c#17#17#01#26#08#1f#0f#50#02#cf#08#40#0f#f7#13#f6#01#26#1f#f7#01#6b#27#e7#1d#81#15#54#00#27#df#2d#06#dd#2b#e2#1d#61#17#56#00#18#9f#af#01#df#2b#bd#1d#49#19#b3#01#0d#bf#3b#03#87#2d#c6#1d#c9#10#cc#03#19#7f#7d#01#d9#2d#ae#1d#f9#13#54#00#34#5f#03#02#6b#2e#aa#1d#6f#14#54#00#30#9f#55#00#6b#2e#9c#1d#65#17#e5#02#34#df#b3#01#e9#2f#99#1d);
end;

The RegWriteDWordValue works, but the RegWriteBinaryValue does not.

The original registry entry with hex is:

"Caldata9"=hex:7c,17,17,01,26,08,1f,0f,50,02,cf,08,40,0f,f7,13,f6,01,26,1f,f7,
01,6b,27,e7,1d,81,15,54,00,27,df,2d,06,dd,2b,e2,1d,61,17,56,00,18,9f,af,01,
df,2b,bd,1d,49,19,b3,01,0d,bf,3b,03,87,2d,c6,1d,c9,10,cc,03,19,7f,7d,01,d9,
2d,ae,1d,f9,13,54,00,34,5f,03,02,6b,2e,aa,1d,6f,14,54,00,30,9f,55,00,6b,2e,
9c,1d,65,17,e5,02,34,df,b3,01,e9,2f,99,1d

How can I do this?

Thanks a lot for your help.


Solution

  • In Pascal in the #dd, the dd is a decimal representation of the character, not hexadecimal. So #7c is not what you think and it won't even compile.

    To use a hexadecimal representation, use #$hh.

    Also note that there should be a comma after the 'Caldata9', not a plus.

    RegWriteBinaryValue(
        HKLM64, 'SYSTEM\CurrentControlSet\services\FIDTPU\Parameters', 'Caldata9',
        #$7c#$17#$17#$01...);