File : reggnatcom.adb
------------------------------------------------------------------------------
-- --
-- GNATCOM - Ada 95 COM/DCOM/COM+ Development Framework and Tools --
-- --
-- R E G G N A T C O M --
-- --
-- $Revision: 1.3 $
-- --
-- Copyright (C) 1999, 2000, 2001 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. --
-- --
-- More information about GNATCOM and the most current public version can --
-- be located on the web at http://www.adapower.com/gnatcom --
-- --
-- Support for GNATCOM is available from Ada Core Technologies, Inc. --
-- --
-- In the U.S., contact Ada Core Technologies at: --
-- Tel: +1 (212) 620 7300 ext 117 --
-- Fax: +1 (212) 807 0162 --
-- Email: sales@gnat.com --
-- --
-- In Europe and elsewhere, contact ACT Europe at: --
-- Tel: +33 1 49 70 67 16 --
-- Fax: +33 1 49 70 05 52 --
-- Email: sales@act-europe.fr --
------------------------------------------------------------------------------
-- This utility will find the location of itself which should be in the
-- directory of the GNATCOM sources and register the GNATCOM 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 RegGNATCOM 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 := "GNATCOM";
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 GNATCOM at location : " & Value);
end;
end RegGNATCOM;