blob: 2538e5df97ca99355f89d46eb20a6312a6fa09bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
with Interfaces.C; use Interfaces.C;
with System; use System;
package body Windows_Default_Path is
subtype DWORD is Interfaces.C.Unsigned_Long;
subtype LPWSTR is String;
subtype HINSTANCE is Address;
function GetModuleFileName (Inst : HINSTANCE; Buf : Address; Size : DWORD)
return DWORD;
pragma Import (Stdcall, GetModuleFileName, "GetModuleFileNameA");
function Get_Windows_Default_Path return String
is
File : String (1 .. 256);
Size : DWORD;
P : Natural;
begin
-- Get exe file path.
Size := GetModuleFileName (Null_Address, File'Address, File'Length);
if Size = 0 or Size = File'Length then
return "{cannot find install path}\lib";
end if;
-- Remove Program file.
P := Natural (Size);
while P > 0 loop
exit when File (P) = '\';
exit when File (P) = ':' and P = 2;
P := P - 1;
end loop;
if File (P) = '\' and P > 1 then
-- Remove directory
P := P - 1;
while P > 0 loop
exit when File (P) = '\';
exit when File (P) = ':' and P = 2;
P := P - 1;
end loop;
end if;
return File (1 .. P) & "lib";
end Get_Windows_Default_Path;
end Windows_Default_Path;
|