=====Simple Registry Usage===== //By JGH, Feb-2007.//\\ \\ The registry is a repository of data maintained by Windows, which holds various information. An application can store configuration or other information from one session to the next within the HKCU/Software/MyPublisher/MyApplication part of the registry, where //MyPublisher// and //MyApplication// are set appropriately.\\ \\ The registry can store various types of data, such as strings, integers, multiple strings, binaries, but you can do simple registry access if you just use string entries.\\ \\ An example program //FredProg// from //BloggSoft// can read settings using code similar to the following:\\ \\ KeyRoot$="Software\BloggSoft\FredProg\" LastSaved$=FNReg_Rd(KeyRoot$+"LastSaved") LoadPath$ =FNReg_Rd(KeyRoot$+"LoadPath") \\ It can later update the registry entries using the following code:\\ \\ KeyRoot$="Software\BloggSoft\FredProg\" PROCReg_Wr(KeyRoot$+"LastSaved",LastSave$) PROCReg_Wr(KeyRoot$+"LoadPath",LoadPath$) \\ You should ensure **KeyRoot$** is formed in the above format to ensure consistency and to ensure the registry names are unique to your application.\\ \\ The example code uses the **Reg_Rd()** and **Reg_Wr()** functions in the [[http://mdfs.net/System/Library/BLib/Win/|Reg]] BASIC library, and listed here:\\ \\ DEF FNReg_Rd(Key$) LOCAL K%,R%,L%,T%,B%,Item$,Value$ Item$=Key$:REPEAT:K%=INSTR(Item$,"\"):IFK%:Item$=MID$(Item$,K%+1) UNTILK%=0:Key$=LEFT$(Key$,LENKey$-LENItem$-1) SYS "RegOpenKeyEx",&80000001,Key$,0,&20001,^K% TO R% IF R%=0 THEN SYS "RegQueryValueEx",K%,Item$,0,^T%,0,^L%:DIM B% LOCAL L% SYS "RegQueryValueEx",K%,Item$,0,^T%,B%,^L% TO R% IF R%=0:Buf%?(L%-1)=13:Value$=$B% SYS "RegCloseKey",K% ENDIF =Value$ DEF PROCReg_Wr(Key$,Value$) LOCAL K%,D%,R%,Item$ Item$=Key$:REPEAT:K%=INSTR(Item$,"\"):IFK%:Item$=MID$(Item$,K%+1) UNTILK%=0:Key$=LEFT$(Key$,LENKey$-LENItem$-1) SYS "RegCreateKeyEx",&80000001,Key$,0,"",0,&F003F,0,^K%,^D% TO R% IF R%=0 THEN SYS "RegSetValueEx",K%,Item$,0,1,Value$,LENValue$+1 SYS "RegCloseKey",K% ENDIF ENDPROC