v2 / vlib / os / const_windows.c.v
144 lines · 118 sloc · 4.93 KB · f09826e928f9612bab9299faefff7cf34a503362
Raw
1module os
2
3const max_path_buffer_size = 2 * max_path_len
4
5// Ref - winnt.h
6const success = 0x0000 // ERROR_SUCCESS
7
8const error_insufficient_buffer = 0x0082
9
10const handle_generic_read = u32(0x80000000)
11const handle_open_existing = 0x00000003
12
13const file_share_read = 0x01
14const file_share_write = 0x02
15const file_share_delete = 0x04
16
17const file_notify_change_file_name = 0x01
18const file_notify_change_dir_name = 0x02
19const file_notify_change_attributes = 0x04
20const file_notify_change_size = 0x08
21const file_notify_change_last_write = 0x10
22const file_notify_change_last_access = 0x20
23const file_notify_change_creation = 0x40
24const file_notify_change_security = 0x80
25
26const file_action_added = 0x01
27const file_action_removed = 0x02
28const file_action_modified = 0x03
29const file_action_renamed_old_name = 0x04
30const file_action_renamed_new_name = 0x05
31
32const file_attr_readonly = 0x00000001
33const file_attr_hidden = 0x00000002
34const file_attr_system = 0x00000004
35const file_attr_directory = 0x00000010
36const file_attr_archive = 0x00000020
37const file_attr_device = 0x00000040
38const file_attr_normal = 0x00000080
39const file_attr_temporary = 0x00000100
40const file_attr_sparse_file = 0x00000200
41const file_attr_reparse_point = 0x00000400
42const file_attr_compressed = 0x00000800
43const file_attr_offline = 0x00001000
44const file_attr_not_content_indexed = 0x00002000
45const file_attr_encrypted = 0x00004000
46const file_attr_integrity_stream = 0x00008000
47const file_attr_virtual = 0x00010000
48const file_attr_no_scrub_data = 0x00020000
49
50const file_type_unknown = 0x00
51const file_type_disk = 0x01
52const file_type_char = 0x02
53const file_type_pipe = 0x03
54
55const file_invalid_file_id = (-1)
56
57const invalid_handle_value = voidptr(-1)
58
59// https://docs.microsoft.com/en-us/windows/console/setconsolemode
60// Input Buffer
61const enable_echo_input = 0x0004
62const enable_extended_flags = 0x0080
63const enable_insert_mode = 0x0020
64const enable_line_input = 0x0002
65const enable_mouse_input = 0x0010
66const enable_processed_input = 0x0001
67const enable_quick_edit_mode = 0x0040
68const enable_window_input = 0x0008
69const enable_virtual_terminal_input = 0x0200
70// Output Screen Buffer
71const enable_processed_output = 0x01
72const enable_wrap_at_eol_output = 0x02
73const enable_virtual_terminal_processing = 0x04
74const disable_newline_auto_return = 0x08
75const enable_lvb_grid_worldwide = 0x10
76
77// File modes
78const o_rdonly = 0x0000 // open the file read-only.
79
80const o_wronly = 0x0001 // open the file write-only.
81
82const o_rdwr = 0x0002 // open the file read-write.
83
84const o_append = 0x0008 // append data to the file when writing.
85
86const o_create = 0x0100 // create a new file if none exists.
87
88const o_binary = 0x8000 // input and output is not translated.
89
90const o_trunc = 0x0200 // truncate regular writable file when opened.
91
92const o_excl = 0x0400 // used with o_create, file must not exist.
93
94const o_sync = 0x0000 // open for synchronous I/O (ignored on Windows)
95
96const o_noctty = 0x0000 // make file non-controlling tty (ignored on Windows)
97
98const o_nonblock = 0x0000
99
100const status_access_violation = u32(0xC0000005)
101const status_in_page_error = u32(0xC0000006)
102const status_invalid_handle = u32(0xC0000008)
103const status_invalid_parameter = u32(0xC000000D)
104const status_no_memory = u32(0xC0000017)
105const status_illegal_instruction = u32(0xC000001D)
106const status_noncontinuable_exception = u32(0xC0000025)
107const status_invalid_disposition = u32(0xC0000026)
108const status_array_bounds_exceeded = u32(0xC000008C)
109const status_float_denormal_operand = u32(0xC000008D)
110const status_float_divide_by_zero = u32(0xC000008E)
111const status_float_inexact_result = u32(0xC000008F)
112const status_float_invalid_operation = u32(0xC0000090)
113const status_float_overflow = u32(0xC0000091)
114const status_float_stack_check = u32(0xC0000092)
115const status_float_underflow = u32(0xC0000093)
116const status_integer_divide_by_zero = u32(0xC0000094)
117const status_integer_overflow = u32(0xC0000095)
118const status_privileged_instruction = u32(0xC0000096)
119const status_stack_overflow = u32(0xC00000FD)
120const status_dll_not_found = u32(0xC0000135)
121const status_ordinal_not_found = u32(0xC0000138)
122const status_entrypoint_not_found = u32(0xC0000139)
123const status_control_c_exit = u32(0xC000013A)
124const status_dll_init_failed = u32(0xC0000142)
125const status_float_multiple_faults = u32(0xC00002B4)
126const status_float_multiple_traps = u32(0xC00002B5)
127const status_reg_nat_consumption = u32(0xC00002C9)
128const status_heap_corruption = u32(0xC0000374)
129const status_stack_buffer_overrun = u32(0xC0000409)
130const status_invalid_cruntime_parameter = u32(0xC0000417)
131const status_assertion_failure = u32(0xC0000420)
132
133// Windows Registry Constants
134pub const hkey_local_machine = voidptr(0x80000002)
135pub const hkey_current_user = voidptr(0x80000001)
136pub const key_query_value = 0x0001
137pub const key_set_value = 0x0002
138pub const key_enumerate_sub_keys = 0x0008
139pub const key_wow64_32key = 0x0200
140
141// Windows Messages
142pub const hwnd_broadcast = voidptr(0xFFFF)
143pub const wm_settingchange = 0x001A
144pub const smto_abortifhung = 0x0002
145