tayto
asked on
Registry Read/Write
Hi all
I'm looking for a way to both read and write a REG_DWord value from/to the registry but without using the registry unit.
I'm looking for a way to both read and write a REG_DWord value from/to the registry but without using the registry unit.
One reason would be size (if making a very small file):
var res: Cardinal;
pc: PChar;
ph: HKEY;
begin
try
pc := PAnsiChar('\.txt');
res := RegOpenKey(HKEY_CLASSES_RO OT,pc,ph);
if res=ERROR_SUCCESS then begin
RegSetValueEx(ph,'',0,REG_ SZ,PChar(A pplication .ExeName), Length(App lication.E xeName)+1) ;
RegCloseKey(ph);
end else begin
MessageBox(0,PChar(SysErro rMessage(r es)),'',0) ;
end;
except
MessageBox(0,'Error while writing to regisgtry','Error',0);
end;
end;
var res: Cardinal;
pc: PChar;
ph: HKEY;
begin
try
pc := PAnsiChar('\.txt');
res := RegOpenKey(HKEY_CLASSES_RO
if res=ERROR_SUCCESS then begin
RegSetValueEx(ph,'',0,REG_
RegCloseKey(ph);
end else begin
MessageBox(0,PChar(SysErro
end;
except
MessageBox(0,'Error while writing to regisgtry','Error',0);
end;
end;
ASKER
I'm making a small program for my own use and prefer not to use the registry unit in delphi unless really needed - Guess i want to do it the hard way so i can learn along the way - i've seen other routines that can access the registry without the delphi registry unit but it didn't work with the REG_DWORD type.
ASKER
thanks ccrdude - but i want to be able to read a REG_WORD value OR write it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ccrdude - i played around with the extra lines you gave to fit them into the routine and all works as wanted.
But I cannot see any reason why you cannot use TRegistry wrapper. Can you explain it?