1(* 2 Copyright (c) 2001, 2015, 2019 3 David C.J. Matthews 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License version 2.1 as published by the Free Software Foundation. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17*) 18structure Globals : 19 sig 20 eqtype 'a HANDLE 21 eqtype HINSTANCE 22 eqtype HWND 23 val hNull : 'a HANDLE 24 val isHNull : 'a HANDLE -> bool 25 26 val ApplicationInstance : unit -> HINSTANCE 27 val GetLastError : unit -> OS.syserror 28 val MainWindow : unit -> HWND 29 end 30 = 31struct 32 local 33 open Foreign 34 open Base 35 in 36 type 'a HANDLE = 'a HANDLE 37 val hNull = hNull 38 and isHNull = isHNull 39 type HINSTANCE = HINSTANCE 40 41 type HWND = HWND 42 43 val GetLastError = Base.GetLastError 44 45 local 46 val getModHandle = 47 winCall1 (kernel "GetModuleHandleA") (cOptionPtr cString) cHINSTANCE 48 (* The current hInstance is also returned as Foreign.System.loadExecutable. *) 49 in 50 fun ApplicationInstance() = getModHandle NONE 51 end 52 53 local 54 val FindWindow = 55 winCall2 (user "FindWindowA") (STRINGOPT, STRINGOPT) cHWND 56 in 57 fun MainWindow() = FindWindow(SOME "PolyMLWindowClass", SOME "Poly/ML") 58 end 59 60 end 61end; 62