with Interfaces; use Interfaces; with Interfaces.C; use Interfaces.C; with System; use System; with Ada.Unchecked_Conversion; procedure Hello is function LoadLibrary (lpFileName : char_array) return Unsigned_32; pragma Import (Stdcall, LoadLibrary, "LoadLibrary", "_LoadLibraryA@4"); function GetProcAddress (hModule : Unsigned_32; lpProcName : char_array) return Address; pragma Import (Stdcall, GetProcAddress, "GetProcAddress", "_GetProcAddress@8"); type MessageBox is access function ( hWnd : Address; lpText : char_array; lpCaption : char_array; uType : Unsigned_16 ) return Integer_16; pragma Convention (Stdcall, MessageBox); function To_MessageBox is new Ada.Unchecked_Conversion (Address, MessageBox); Result : Integer_16; Library : Unsigned_32; Pointer : Address; begin Library := LoadLibrary (To_C ("user32.dll")); Pointer := GetProcAddress (Library, To_C ("MessageBoxA")); Result := To_MessageBox (Pointer) ( Null_Address, To_C ("Hello, Win32 API(Ada) World!"), To_C ("Hello, World!"), 0 ); end Hello;