WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Export a Color Scheme from the Registry and Save to a File

Keywords:   export color scheme

Question:

I'd like to write/export a single "color-scheme" to a file with the registry functions of Winbatch. This file should have the format/size of a "normal reg-file", e.g.
Regedit4
[Hkey_current_user\Control Panel\Appearance\Schemes]
"Schemename"=hex:00,01,00,01,......
EOF
Unfortunately it is not possible to export a single Color-scheme with the export-function of regedit.

Answer:

Here is some code that seems to work.
keyname="Control Panel\Appearance\Schemes"
dataitem="brick"
filename="myscheme.reg"
;- - - -
Scheme=strcat(keyname,"[",dataitem,"]")
stuff=RegQueryBin(@REGCURRENT,Scheme)
;Message("Stuff",stuff)

bb=BinaryAlloc(100000)   ; allocate work space
ptr=0
ptr=ptr+BinaryPokeStr(bb,ptr,strcat("REGEDIT4",@CRLF,@CRLF))
ptr=ptr+BinaryPokeStr(bb,ptr,strcat("[",keyname,"]",@crlf))
ptr=ptr+BinaryPokeStr(bb,ptr,strcat('"',dataitem,'"=hex:'))

stuff=strreplace(stuff," ",",")
stuffsize=strlen(stuff)
indent=0

while stuffsize>60
   part=strsub(stuff,1,60)
   stuff=strsub(stuff,61,-1)
   stuffsize=strlen(stuff)
   if indent==0
      indent=1
   else
      ptr=ptr+BinaryPokeStr(bb,ptr,"  ")
   endif
   ptr=ptr+BinaryPokeStr(bb,ptr,strcat(part,"\",@crlf))
endwhile 

if indent==1
   ptr=ptr+BinaryPokeStr(bb,ptr,"  ")
endif
ptr=ptr+BinaryPokeStr(bb,ptr,strcat(stuff,@crlf))

BinaryWrite(bb,filename)
BinaryFree(bb)
Message("Complete.   See",filename)

Article ID:   W13718
Filename:   Export Color Scheme from Registry.txt
File Created: 1999:04:15:16:55:54
Last Updated: 1999:04:15:16:55:54