Solved

Writing to the registry in Windows 95

Posted on 2001-07-04
3
132 Views
Last Modified: 2010-04-06
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?
0
Comment
Question by:geofizzydrink
3 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6251674
What does ReadInteger('98') do? Does the key '98' exist?
0
 
LVL 4

Accepted Solution

by:
jsweby earned 200 total points
ID: 6251695
I have often come across the error "Failed to set data for <KEY>" & it has always, without fail, been the following problem (which doesn't sound applicable to you but I thought I'd share it with you in case it helps):

This always comes up for us on NT workstations where the administrator has not allowed the user to modify the registry; each individual key can be set on NT Server to be modified or not by particular users. If your 95 machine which has the problem is part of an NT network, make sure the users have registry permissions, at the very least for the key(s) you want to change. The program on NT Server is called regsvr32.

J.
0
 
LVL 11

Expert Comment

by:Goodangel Matope
ID: 6252121
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question