------------------------------------------------------------------------------ -- -- -- -- -- R E G C L A W -- -- -- -- $Revision: 1.0 $ -- -- -- Copyright (C) 2002 David Botton -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. It is distributed in the hope that it will be useful, but WITHOUT -- -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -- -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with this; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- ------------------------------------------------------------------------------ -- This utility will find the location of itself which should be in the -- directory of the CLAW sources and register the CLAW sources -- as a standard GNAT library in the Win32 Registry with Ada.Strings.Fixed; use Ada.Strings.Fixed; use Ada.Strings; with Interfaces.C; with GNATCOM.Register; use GNATCOM.Register; with GNATCOM.Types; with GNAT.IO; use GNAT.IO; procedure RegCLAW is pragma Linker_Options ("-lole32"); pragma Linker_Options ("-loleaut32"); use type Interfaces.C.int; FILE_NAME_ERROR : exception; function GetModuleFileName (hInst : Interfaces.C.long; lpszFileName : Interfaces.C.char_array; cbFileName : Interfaces.C.int) return Interfaces.C.int; pragma Import (StdCall, GetModuleFileName, "GetModuleFileNameA"); procedure GetShortPathName (lpszLongPath : Interfaces.C.char_array; lpszShortPath : Interfaces.C.char_array; cchBuffer : GNATCOM.Types.DWORD); pragma Import (StdCall, GetShortPathName, "GetShortPathNameA"); function Retrieve_hInstance return Interfaces.C.long; pragma Import (C, Retrieve_hInstance, "rts_get_hInstance"); MAX_PATH : constant := 1024; ServerPath : aliased Interfaces.C.char_array (1 .. MAX_PATH) := (others => Interfaces.C.nul); KeyName : String := "SOFTWARE\Ada Core Technologies\GNAT\Standard Libraries"; Name : String := "CLAW"; begin if GetModuleFileName (Retrieve_hInstance, ServerPath, MAX_PATH) < 0 then raise FILE_NAME_ERROR; end if; GetShortPathName (ServerPath, ServerPath, MAX_PATH); declare Tmp : String := Interfaces.C.To_Ada (ServerPath); Value : String := Tmp (1 .. Index (Tmp, "\", Backward) - 1); begin Register (KeyName, Name, Value, HKEY_LOCAL_MACHINE); Put_Line ("Registered CLAW at location : " & Value); end; end RegCLAW;