bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/82573] New: GNAT.Registry doesn't read/write with HKEY_LO


From: hudsonjk at astound dot net
Subject: [Bug classpath/82573] New: GNAT.Registry doesn't read/write with HKEY_LOCAL_MACHINE.
Date: Mon, 16 Oct 2017 23:58:14 +0000

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82573

            Bug ID: 82573
           Summary: GNAT.Registry doesn't read/write with
                    HKEY_LOCAL_MACHINE.
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hudsonjk at astound dot net
  Target Milestone: ---

Bug report - GNAT.Registry
Submitted by Jerry Hudson, address@hidden

Nature of the bug:
-----------------
Package seems to work as advertized when reading/writing keys
in HKEY_CURRENT_USER.  It seems to work with HKEY_LOCAL_MACHINE,
until you do a regedit and see that nothing gets written there!

I don't know where it was putting the keys and strings.  I did
a registry search on the key SOFTWARE\TestGNATReg (see code
listing below), and it was nowhere in the registry.  On the other
hand, writing/reading with HKEY_CURRENT_USER made visible entries
in the registry as seen by regedit.

In the testing below, USER HAS ADMIN PRIVILEGES.

Test program
-------------

------------------------------------------------------------------
-- Test GNAT.Registry

with Ada.Text_IO;                    use Ada.Text_IO;
with GNAT.Registry;                  use GNAT.Registry;


procedure Test_GNAT_Registry is

   key    : HKEY;
   txt    : String(1..20);
   len    : Integer;
   skey   : HKEY;

begin

-- Choose which standard key to use
   Put( "Which standard key to use? (HKCU, HKLM): " );
   Get_Line( txt, len );
   if txt(1..4) = "HKCU" then
      skey  := HKEY_CURRENT_USER;
      Put_Line( "HKEY_CURRENT_USER" );
   elsif txt(1..4) = "HKLM" then
      skey  := HKEY_LOCAL_MACHINE;
      Put_Line( "HKEY_LOCAL_MACHINE" );
   else
      Put_Line( "Didn't understand: " & txt(1..len) );
      Put_Line( "Needs to be: HKCU or HKLM" );
      return;
   end if;

-- Create new registry key and a couple of strings
   if not Key_Exists(
      From_Key  => skey,
      Sub_Key   => "SOFTWARE\TestGNATReg" )
   then
      if skey = HKEY_LOCAL_MACHINE then
         Put_Line("Creating key under HKEY_LOCAL_MACHINE");
      else
         Put_Line("Creating key under HKEY_CURRENT_USER");
      end if;
      key  := Create_Key(
         From_Key  => skey,
         Sub_Key   => "SOFTWARE\TestGNATReg",
         Mode      => Read_Write );
      Set_Value(
         From_Key  => key,
         Sub_Key   => "State",
         Value     => "CA",
         Expand    => False );
      Set_Value(
         From_Key  => key,
         Sub_Key   => "City",
         Value     => "Concord",
         Expand    => False );
      Close_Key( key );
   end if;

-- Read back whatever is in the key
   if not Key_Exists(
      From_Key  => skey,
      Sub_Key   => "SOFTWARE\TestGNATReg" )
   then
      Put_Line( "Oops - no such key: SOFTWARE\TestGNATReg" );
      return;
   end if;
   if skey = HKEY_CURRENT_USER then
      Put_Line("Opening key under HKEY_CURRENT_USER");
   else
      Put_Line("Opening key under HKEY_LOCAL_MACHINE");
   end if;
   key   := Open_Key(
      From_Key   => skey,
      Sub_Key    => "SOFTWARE\TestGNATReg" );
   Put_Line( "State : " & Query_Value( key, "State" ) );
   Put_Line( "City  : " & Query_Value( key, "City" ) );
   Close_Key( key );
   Put_Line( "Looks good!" );

end Test_GNAT_Registry;
------------------------------------------------------------------

Build:
-----
C:\Users\Hektor\Documents\Code\Test\Registry>gnatmake test_gnat_registry.adb
gcc -c test_gnat_registry.adb
gnatbind -x test_gnat_registry.ali
gnatlink test_gnat_registry.ali

Successful run:
---------------

C:\Users\Hektor\Documents\Code\Test\Registry>test_gnat_registry
Which standard key to use? (HKCU, HKLM): HKCU
HKEY_CURRENT_USER
Creating key under HKEY_CURRENT_USER
Opening key under HKEY_CURRENT_USER
State : CA
City  : Concord
Looks good!

Key and data appear in the registry as seen by regedit.

Unsuccessful run:
----------------

Identical except user says "HKLM".  Program appears to have created
the key and string values, and to have read them correctly.  However,
NOTHING GETS IN THE REGISTRY! 

More detailed testing revealed that stuff that is REALLY in the
HKEY_LOCAL_MACHINE cannot be read/written.  I can provide a program
that does more detailed testing if you like, but it is more complex.



gcc Version
-----------

C:\Users\Hektor\Documents\Code\Test\Registry>gcc -c -v
Using built-in specs.
COLLECT_GCC=gcc
Target: i686-pc-mingw32
Configured with: ../src/configure --enable-languages=ada,c,c++
--enable-threads=win32 --enable-lto --with-fpmath=sse --enable-dual-exceptions
--disable-sjlj-exceptions --enable-frame-pointer
--with-bugurl=URL:mailto:address@hidden --disable-nls
--without-libiconv-prefix --disable-libstdcxx-pch --disable-libada
--enable-checking=release
--with-mpfr=/gnatmail/sandbox/2017/x86-windows/mpfr_stable/install
--with-gmp=/gnatmail/sandbox/2017/x86-windows/gmp_stable/install
--with-mpc=/gnatmail/sandbox/2017/x86-windows/mpc_stable/install
--with-build-time-tools=/gnatmail/sandbox/2017/x86-windows/gcc/build/buildtools/bin
--prefix=/gnatmail/sandbox/2017/x86-windows/gcc/pkg --build=i686-pc-mingw32
Thread model: win32
gcc version 6.3.1 20170510 (for GNAT GPL 2017 20170515) (GCC)

C:\Users\Hektor\Documents\Code\Test\Registry>gnatmake test_gnat_registry.adb
gcc -c test_gnat_registry.adb
gnatbind -x test_gnat_registry.ali
gnatlink test_gnat_registry.ali

System info
-----------

Windows edition
        Windows 10 Home

System: 
        Processor:      Intel Pentium CPU N3700 @1.60GHz
        Installed RAM:  4.00 GB
        System type:    64-bit Operating System, x64-based processor


reply via email to

[Prev in Thread] Current Thread [Next in Thread]