https://github.com/musm/wintypes.jl
Julia aliases for Windows data types
https://github.com/musm/wintypes.jl
julia windows
Last synced: 9 months ago
JSON representation
Julia aliases for Windows data types
- Host: GitHub
- URL: https://github.com/musm/wintypes.jl
- Owner: musm
- License: mit
- Created: 2020-07-23T04:57:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T17:08:32.000Z (over 5 years ago)
- Last Synced: 2025-07-18T00:41:59.986Z (11 months ago)
- Topics: julia, windows
- Language: Julia
- Homepage: https://musm.github.io/WinTypes.jl
- Size: 151 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WinTypes.jl
This package defines aliases in Julia to [Windows Data types](https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types).
[](https://musm.github.io/WinTypes.jl)
### Installation
```julia
pkg> add WinTypes
```
## Motivation & Examples
The point of this package is to make it easier and more convenient to wrap Windows API function calls in Julia.
As a consequence, this package also improves readability with respect to the original Windows API function definitions.
Here's an example comparing wraping Windows API functions with and without `WinTypes`:
**Using `WinTypes` a Windows API call would look something like:**
```julia
using WinTypes: HANDLE, DWORD, BOOL
function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, HANDLE, (DWORD,), STD_OUTPUT_HANDLE % DWORD)
dwMode = Ref{DWORD}()
ccall(:GetConsoleMode, stdcall, BOOL, (HANDLE, Ref{DWORD}), hOutput, dwMode)
return dwMode[]
end
```
Compare this to the call without this package:
```julia
function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, Ptr{Cvoid}, (UInt32,), STD_OUTPUT_HANDLE % UInt32)
dwMode = Ref{UInt32}()
ccall(:GetConsoleMode, stdcall, Int32, (Ref{Cvoid}, Ref{UInt32}), hOutput, dwMode)
return dwMode[]
end
```
Finally, here are the corresponding Windows API function syntax definitions in `C`:
```c
HANDLE WINAPI GetStdHandle(
_In_ DWORD nStdHandle
);
```
```c
BOOL WINAPI GetConsoleMode(
_In_ HANDLE hConsoleHandle,
_Out_ LPDWORD lpMode
);
```
Using `WinTypes` to wrap these APIs is both simpler and more readible, making it easier without having to manually look up the corresponding Windows data types.
## Alias List
Refer to
[https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types](https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types)
for detailed documentation on each constant.
```julia
FALSE = Cint(0)
TRUE = Cint(1)
BYTE = Cuchar
WORD = Cushort
DWORD = Culong
DWORDLONG = UInt64
DWORD32 = UInt32
DWORD64 = UInt64
BOOL = Cint
BOOLEAN = BYTE
CHAR = Cchar
CCHAR = Cchar
FLOAT = Cfloat
LONG = Culong
ULONG = Culong
LONG32 = Cint
LONG64 = Int64
LONG_PTR = Int
SHORT = Cshort
USHORT = Cushort
ATOM = WORD
LANGID = WORD
COLORREF = DWORD
LGRPID = DWORD
LCTYPE = DWORD
LCID = DWORD
INT = Int32
INT8 = Int8
INT16 = Int16
INT32 = Int32
INT64 = Int64
INT_PTR = Int
UINT_PTR = UInt
WPARAM = UINT_PTR
LPARAM = LONG_PTR
HANDLE = Ptr{Cvoid}
HACCEL = HANDLE
HBITMAP = HANDLE
HBRUSH = HANDLE
HCOLORSPACE = HANDLE
HCONV = HANDLE
HCONVLIST = HANDLE
HDC = HANDLE
HDDEDATA = HANDLE
HDESK = HANDLE
HDROP = HANDLE
HDWP = HANDLE
HENHMETAFILE = HANDLE
HFILE = Cint
HFONT = HANDLE
HGDIOBJ = HANDLE
HGLOBAL = HANDLE
HHOOK = HANDLE
HICON = HANDLE
HCURSOR = HICON
HINSTANCE = HANDLE
HKEY = HANDLE
HKL = HANDLE
HLOCAL = HANDLE
HMENU = HANDLE
HMETAFILE = HANDLE
HMODULE = HANDLE
HMONITOR = HANDLE
HPALETTE = HANDLE
HPEN = HANDLE
HRESULT = Clong
HRGN = HANDLE
HRSRC = HANDLE
HSZ = HANDLE
HWINSTA = HANDLE
HWND = HANDLE
PHANDLE = Ptr{HANDLE}
UCHAR = Cuchar
WCHAR = Cwchar_t
PWCHAR = Ptr{WCHAR}
PWORD = Ptr{WORD}
LPWORD = Ptr{WORD}
PDWORD = Ptr{DWORD}
LPDWORD = Ptr{DWORD}
VOID = Cvoid
PVOID = Ptr{Cvoid}
LPVOID = Ptr{Cvoid}
LPCVOID = Ptr{Cvoid}
LPINT = Ptr{Cint}
PINT = Ptr{Cint}
PSTR = Ptr{CHAR}
PCSTR = Ptr{CHAR}
LPSTR = Ptr{CHAR}
LPCSTR = Ptr{CHAR}
PWSTR = Ptr{WCHAR}
PCWSTR = Ptr{WCHAR}
LPWSTR = Ptr{WCHAR}
LPCWSTR = Ptr{WCHAR}
```