Link to home
Start Free TrialLog in
Avatar of geofizzydrink
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?
Avatar of Epsylon
Epsylon

What does ReadInteger('98') do? Does the key '98' exist?
ASKER CERTIFIED SOLUTION
Avatar of Jason Sweby
Jason Sweby
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Goodangel Matope
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.