geofizzydrink
asked on
Writing to the registry in Windows 95
I have written an application that uses the windows registry to store an integer value, and when required, read and modify that integer value.
The Following code shows this, Note that "<Registry Path>" represents the path to the applications Registry Key.
Reg := TRegistry.Create;
with Reg do
begin
try
begin
Rootkey := HKEY_LOCAL_MACHINE;
OpenKey(<Registry Path>,True);
if not ValueExists('IntegerValue' ) then
begin
WriteInteger('IntegerValue ',0);
BookingStatsReportCount := 0;
end
else
begin
BookingStatsReportCount := ReadInteger('98');
end;
Reg.CloseKey;
end;
finally
Reg.Free;
end;
end;
This code works fine for Windows 98, Me, and NT4, but when the application is installed and run in windows 95 I get a runtime error like:
"Error: Failed to set data 'IntegerValue' Data was not written"
Is there something with the registry in Windows 95 that is different to later versions?
If so, How can I get around this problem other than recommending that the application not be run under windows 95?
The Following code shows this, Note that "<Registry Path>" represents the path to the applications Registry Key.
Reg := TRegistry.Create;
with Reg do
begin
try
begin
Rootkey := HKEY_LOCAL_MACHINE;
OpenKey(<Registry Path>,True);
if not ValueExists('IntegerValue'
begin
WriteInteger('IntegerValue
BookingStatsReportCount := 0;
end
else
begin
BookingStatsReportCount := ReadInteger('98');
end;
Reg.CloseKey;
end;
finally
Reg.Free;
end;
end;
This code works fine for Windows 98, Me, and NT4, but when the application is installed and run in windows 95 I get a runtime error like:
"Error: Failed to set data 'IntegerValue' Data was not written"
Is there something with the registry in Windows 95 that is different to later versions?
If so, How can I get around this problem other than recommending that the application not be run under windows 95?
What does ReadInteger('98') do? Does the key '98' exist?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can try to use TRegIniFile instead of TRegistry, It was meant for use with Windows 3.x but it works with Win95. That was what I used to use for Win95 applications.