package opam-core

  1. Overview
  2. Docs

OS-specific functions requiring C code on at least one platform.

Most functions are Windows-specific and raise an exception on other platforms.

include module type of struct include OpamStubsTypes end
type console_screen_buffer_info = OpamStubsTypes.console_screen_buffer_info = {
  1. size : int * int;
    (*

    Width and height of the screen buffer

    *)
  2. cursorPosition : int * int;
    (*

    Current position of the console cursor (caret)

    *)
  3. attributes : int;
    (*

    Screen attributes; see https://docs.microsoft.com/en-us/windows/console/console-screen-buffers#_win32_character_attributes

    *)
  4. window : int * int * int * int;
    (*

    Coordinates of the upper-left and lower-right corners of the display window within the screen buffer

    *)
  5. maximumWindowSize : int * int;
    (*

    Maximum displayable size of the console for this screen buffer

    *)
}

CONSOLE_SCREEN_BUFFER_INFO struct (see https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str)

type console_font_infoex = OpamStubsTypes.console_font_infoex = {
  1. font : int;
    (*

    Index in the system's console font table

    *)
  2. fontSize : int * int;
    (*

    Size, in logical units, of the font

    *)
  3. fontFamily : int;
    (*

    Font pitch and family (low 8 bits only). See tmPitchAndFamily in https://msdn.microsoft.com/library/windows/desktop/dd145132

    *)
  4. fontWeight : int;
    (*

    Font weight. Normal = 400; Bold = 700

    *)
  5. faceName : string;
    (*

    Name of the typeface

    *)
}

CONSOLE_FONT_INFOEX struct (see https://docs.microsoft.com/en-us/windows/console/console-font-infoex)

type handle = OpamStubsTypes.handle

Win32 API handles

type stdhandle = OpamStubsTypes.stdhandle =
  1. | STD_INPUT_HANDLE
  2. | STD_OUTPUT_HANDLE
  3. | STD_ERROR_HANDLE

Standard handle constants (see https://docs.microsoft.com/en-us/windows/console/getstdhandle)

type registry_root = OpamStubsTypes.registry_root =
  1. | HKEY_CLASSES_ROOT
  2. | HKEY_CURRENT_CONFIG
  3. | HKEY_CURRENT_USER
  4. | HKEY_LOCAL_MACHINE
  5. | HKEY_USERS

Win32 Root Registry Hives (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724836.aspx)

type _ registry_value = _ OpamStubsTypes.registry_value =
  1. | REG_SZ : string registry_value

Win32 Registry Value Types (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884.aspx

type shGFP_type = OpamStubsTypes.shGFP_type =
  1. | SHGFP_TYPE_CURRENT
    (*

    Retrieve the current path

    *)
  2. | SHGFP_TYPE_DEFAULT
    (*

    Retrieve the default path

    *)

SHGetFolderPath flags

type ('a, 'b, 'c) winmessage = ('a, 'b, 'c) OpamStubsTypes.winmessage =
  1. | WM_SETTINGCHANGE : (int, string, int) winmessage
    (*

    See https://msdn.microsoft.com/en-us/library/windows/desktop/ms725497.aspx

    *)

Windows Messages (at least, one of them!)

val getpid : unit -> int

On Windows, this returns the actual process ID, rather than the non-unique faked process ID returned by the Microsoft C Runtime (see https://caml.inria.fr/mantis/view.php?id=4034).

On all other platforms, this is just an alias for Unix.getpid.

val getCurrentProcessID : unit -> int32

Windows only. As getpid, but without the possibility of truncating the ID on 32-bit platforms.

val getStdHandle : stdhandle -> handle

Windows only. Return a standard handle.

val getConsoleScreenBufferInfo : handle -> console_screen_buffer_info

Windows only. Return current Console screen buffer information.

val setConsoleTextAttribute : handle -> int -> unit

Windows only. Set the console's text attribute setting.

val fillConsoleOutputCharacter : handle -> char -> int -> (int * int) -> bool

Windows only. fillConsoleOutputCharacter buffer c n (x, y) writes c n times starting at the given coordinate (and wrapping if required).

val getConsoleMode : handle -> int

Windows only. Returns the input/output mode of the console screen buffer referred to by the handle.

  • raises Not_found

    If the handle does not refer to a console.

val setConsoleMode : handle -> int -> bool

Windows only. Sets the input/output mode of the console screen buffer referred to by the handle, returning true if the operation isr successful.

val getWindowsVersion : unit -> int * int * int * int

Windows only. Returns the Windows version as (major, minor, build, revision). This function only works if opam is compiled OCaml 4.06.0 or later, it returns (0, 0, 0, 0) otherwise.

val isWoW64 : unit -> bool

Returns false unless this process is a 32-bit Windows process running in the WoW64 sub-system (i.e. is being run on 64-bit Windows).

val waitpids : int list -> int -> int * Unix.process_status

Windows only. Given a list pids with length elements, waitpids pids length behaves like Unix.wait, returning the pid and exit status of the first process to terminate.

val writeRegistry : registry_root -> string -> string -> 'a registry_value -> 'a -> unit

Windows only. writeRegistry root key name value_type value sets the value name of type value_type in registry key key of root to value.

  • raises Failure

    If the value could not be set.

val getConsoleOutputCP : unit -> int

Windows only. Retrieves the current Console Output Code Page.

val getCurrentConsoleFontEx : handle -> bool -> console_font_infoex

Windows only. Gets information on the current console output font.

val create_glyph_checker : string -> handle * handle

Windows only. Given a font name, returns a pair consisting of a screen DC and a font object, which will have been selected into the DC.

  • raises Failure

    If anything goes wrong with the GDI calls.

val delete_glyph_checker : (handle * handle) -> unit

Windows only. Given (dc, font), deletes the font object and releases the DC.

val has_glyph : (handle * handle) -> OpamCompat.Uchar.t -> bool

Windows only. has_glyph (dc, font) scalar returns true if font contains a glyph for scalar.

  • raises Failure

    If the call to GetGlyphIndicesW fails.

val isWoW64Process : int32 -> bool

Windows only. General version of isWoW64 for any given process ID. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms684139.aspx

val process_putenv : int32 -> string -> string -> bool

Windows only. process_putenv pid name value sets the environment variable name to value in given process ID (Unix.putenv must also be called to update the value in the current process). This function must not be called if the target process is 32-bit and the current process is 64-bit or vice versa (outcomes vary from a no-op to a segfault).

val shGetFolderPath : int -> shGFP_type -> string

Windows only. shGetFolderPath nFolder dwFlags retrieves the location of a special folder by CSIDL value. See https://msdn.microsoft.com/en-us/library/windows/desktop/bb762181.aspx

val sendMessageTimeout : nativeint -> int -> int -> ('a, 'b, 'c) winmessage -> 'a -> 'b -> int * 'c

Windows only. sendMessageTimeout hwnd timeout flags message wParam lParam sends a message to the given handle, but is guaranteed to return within timeout milliseconds. The result consists of two parts, fst is the return value from SendMessageTimeout, snd depends on both the message and fst. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952.aspx

val getParentProcessID : int32 -> int32

Windows only. getParentProcessID pid returns the process ID of the parent of pid.

  • raises Failure

    If walking the process tree fails to find the process.

val getConsoleAlias : string -> string -> string

Windows only. getConsoleAlias alias exeName retrieves the value for a given executable or "" if the alias is not defined. See https://docs.microsoft.com/en-us/windows/console/getconsolealias

val win_create_process : string -> string -> string option -> Unix.file_descr -> Unix.file_descr -> Unix.file_descr -> int

Windows only. Provided by OCaml's win32unix library.

OCaml

Innovation. Community. Security.