windows-pr 0.3.0-mswin32 → 0.4.0-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ = 0.4.0 - 7-May-2006
2
+ * Bug fix for the WaitForMultipleObjects method in synchronize.rb
3
+ * Added the Window module (just a few constants for now)
4
+ * Added the Console module (AttachConsole, etc)
5
+ * Added the Library module (LoadLibrary, etc)
6
+ * Added the Directory module (CreateDirectory, etc)
7
+ * Added the Shell module (some constants, a few methods for now)
8
+ * Added the Unicode module (WideCharToMultiByte, etc)
9
+ * Added process creation, priority and startf flags to process.rb
10
+
1
11
  = 0.3.0 - 22-Apr-2006
2
12
  * Added the limits module.
3
13
  * Added the security module.
@@ -0,0 +1,323 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Console
5
+ CTRL_C_EVENT = 0
6
+ CTRL_BREAK_EVENT = 1
7
+ CTRL_LOGOFF_EVENT = 5
8
+ CTRL_SHUTDOWN_EVENT = 6
9
+
10
+ ENABLE_PROCESSED_INPUT = 0x0001
11
+ ENABLE_LINE_INPUT = 0x0002
12
+ ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002
13
+ ENABLE_ECHO_INPUT = 0x0004
14
+ ENABLE_WINDOW_INPUT = 0x0008
15
+ ENABLE_MOUSE_INPUT = 0x0010
16
+ ENABLE_INSERT_MODE = 0x0020
17
+ ENABLE_QUICK_EDIT_MODE = 0x0040
18
+
19
+ STD_INPUT_HANDLE = -10
20
+ STD_OUTPUT_HANDLE = -11
21
+ STD_ERROR_HANDLE = -12
22
+
23
+ # Console window constants
24
+ FOREGROUND_BLUE = 0x0001
25
+ FOREGROUND_GREEN = 0x0002
26
+ FOREGROUND_RED = 0x0004
27
+ FOREGROUND_INTENSITY = 0x0008
28
+ BACKGROUND_BLUE = 0x0010
29
+ BACKGROUND_GREEN = 0x0020
30
+ BACKGROUND_RED = 0x0040
31
+ BACKGROUND_INTENSITY = 0x0080
32
+ COMMON_LVB_LEADING_BYTE = 0x0100
33
+ COMMON_LVB_TRAILING_BYTE = 0x0200
34
+ COMMON_LVB_GRID_HORIZONTAL = 0x0400
35
+ COMMON_LVB_GRID_LVERTICAL = 0x0800
36
+ COMMON_LVB_GRID_RVERTICAL = 0x1000
37
+ COMMON_LVB_REVERSE_VIDEO = 0x4000
38
+ COMMON_LVB_UNDERSCORE = 0x8000
39
+ COMMON_LVB_SBCSDBCS = 0x0300
40
+
41
+ CONSOLE_FULLSCREEN = 1
42
+ CONSOLE_OVERSTRIKE = 1
43
+ CONSOLE_FULLSCREEN_HARDWARE = 2
44
+
45
+ AddConsoleAlias = Win32API.new('kernel32', 'AddConsoleAlias', 'PPP', 'I')
46
+ AllocConsole = Win32API.new('kernel32', 'AllocConsole', 'V', 'I')
47
+ AttachConsole = Win32API.new('kernel32', 'AttachConsole', 'L', 'I')
48
+ CreateConsoleScreenBuffer = Win32API.new('kernel32', 'CreateConsoleScreenBuffer', 'LLPLP', 'L')
49
+ FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', 'LILLP', 'I')
50
+ FillConsoleOutputCharacter = Win32API.new('kernel32', 'FillConsoleOutputCharacter', 'LILLP', 'I')
51
+ FlushConsoleInputBuffer = Win32API.new('kernel32', 'FlushConsoleInputBuffer', 'L', 'I')
52
+ FreeConsole = Win32API.new('kernel32', 'FreeConsole', 'V', 'I')
53
+ GenerateConsoleCtrlEvent = Win32API.new('kernel32', 'GenerateConsoleCtrlEvent', 'LL', 'I')
54
+ GetConsoleAlias = Win32API.new('kernel32', 'GetConsoleAlias', 'PPLP', 'L')
55
+ GetConsoleAliases = Win32API.new('kernel32', 'GetConsoleAliases', 'PLP', 'L')
56
+ GetConsoleAliasesLength = Win32API.new('kernel32', 'GetConsoleAliasesLength', 'P', 'L')
57
+ GetConsoleAliasExes = Win32API.new('kernel32', 'GetConsoleAliasExes', 'PL', 'L')
58
+ GetConsoleAliasExesLength = Win32API.new('kernel32', 'GetConsoleAliasExesLength', 'V', 'L')
59
+ GetConsoleCP = Win32API.new('kernel32', 'GetConsoleCP', 'V', 'I')
60
+ GetConsoleCursorInfo = Win32API.new('kernel32', 'GetConsoleCursorInfo', 'LP', 'I')
61
+ GetConsoleDisplayMode = Win32API.new('kernel32', 'GetConsoleDisplayMode', 'P', 'L')
62
+ GetConsoleFontSize = Win32API.new('kernel32', 'GetConsoleFontSize', 'LL', 'L')
63
+ GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', 'LP', 'I')
64
+ GetConsoleOutputCP = Win32API.new('kernel32', 'GetConsoleOutputCP', 'V', 'I')
65
+ GetConsoleProcessList = Win32API.new('kernel32', 'GetConsoleProcessList', 'PL', 'L')
66
+ GetConsoleScreenBufferInfo = Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', 'LP', 'I')
67
+ GetConsoleSelectionInfo = Win32API.new('kernel32', 'GetConsoleSelectionInfo', 'P', 'I')
68
+ GetConsoleTitle = Win32API.new('kernel32', 'GetConsoleTitle', 'PL', 'L')
69
+ GetConsoleWindow = Win32API.new('kernel32', 'GetConsoleWindow', 'V', 'L')
70
+ GetCurrentConsoleFont = Win32API.new('kernel32', 'GetCurrentConsoleFont' , 'LIP', 'I')
71
+ GetLargestConsoleWindowSize = Win32API.new('kernel32', 'GetLargestConsoleWindowSize', 'L', 'L')
72
+ GetNumberOfConsoleInputEvents = Win32API.new('kernel32', 'GetNumberOfConsoleInputEvents', 'LP', 'I')
73
+ GetNumberOfConsoleMouseButtons = Win32API.new('kernel32', 'GetNumberOfConsoleMouseButtons', 'L', 'I')
74
+ GetStdHandle = Win32API.new('kernel32', 'GetStdHandle', 'L', 'L')
75
+ PeekConsoleInput = Win32API.new('kernel32', 'PeekConsoleInput', 'LPLP', 'I')
76
+ ReadConsole = Win32API.new('kernel32', 'ReadConsole', 'LPLPP', 'I')
77
+ ReadConsoleInput = Win32API.new('kernel32', 'ReadConsoleInput', 'LPLP', 'I')
78
+ ReadConsoleOutput = Win32API.new('kernel32', 'ReadConsoleOutput', 'LPLLP', 'I')
79
+ ReadConsoleOutputAttribute = Win32API.new('kernel32', 'ReadConsoleOutputAttribute', 'LPLLP', 'I')
80
+ ReadConsoleOutputCharacter = Win32API.new('kernel32', 'ReadConsoleOutputCharacter', 'LPLLP', 'I')
81
+ ScrollConsoleScreenBuffer = Win32API.new('kernel32', 'ScrollConsoleScreenBuffer', 'LPPLP', 'I')
82
+ SetConsoleActiveScreenBuffer = Win32API.new('kernel32', 'SetConsoleActiveScreenBuffer', 'L', 'I')
83
+ SetConsoleCommandHistoryMode = Win32API.new('kernel32', 'SetConsoleCommandHistoryMode', 'L', 'I')
84
+ SetConsoleCP = Win32API.new('kernel32', 'SetConsoleCP', 'L', 'I')
85
+ SetConsoleCtrlHandler = Win32API.new('kernel32', 'SetConsoleCtrlHandler', 'PI', 'I')
86
+ SetConsoleCursorInfo = Win32API.new('kernel32', 'SetConsoleCursorInfo', 'LP', 'I')
87
+ SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', 'LP', 'I')
88
+ SetConsoleDisplayMode = Win32API.new('kernel32', 'SetConsoleDisplayMode', 'LLP', 'I')
89
+ SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', 'LL', 'I')
90
+ SetConsoleOutputCP = Win32API.new('kernel32', 'SetConsoleOutputCP', 'I', 'I')
91
+ SetConsoleScreenBufferSize = Win32API.new('kernel32', 'SetConsoleScreenBufferSize', 'LL', 'I')
92
+ SetConsoleTextAttribute = Win32API.new('kernel32', 'SetConsoleTextAttribute', 'LL', 'I')
93
+ SetConsoleTitle = Win32API.new('kernel32', 'SetConsoleTitle', 'P', 'I')
94
+ SetConsoleWindowInfo = Win32API.new('kernel32', 'SetConsoleWindowInfo', 'LIP', 'I')
95
+ SetStdHandle = Win32API.new('kernel32', 'SetStdHandle', 'LL', 'I')
96
+ WriteConsole = Win32API.new('kernel32', 'WriteConsole', 'LPLPP', 'I')
97
+ WriteConsoleInput = Win32API.new('kernel32', 'WriteConsoleInput', 'LPLP', 'I')
98
+ WriteConsoleOutput = Win32API.new('kernel32', 'WriteConsoleOutput', 'LPLLP', 'I')
99
+ WriteConsoleOutputAttribute = Win32API.new('kernel32', 'WriteConsoleOutputAttribute', 'LPLLP', 'I')
100
+ WriteConsoleOutputCharacter = Win32API.new('kernel32', 'WriteConsoleOutputCharacter', 'LPLLP', 'I')
101
+
102
+ def AddConsoleAlias(source, target, exe)
103
+ AddConsoleAlias.call(source, target, exe) != 0
104
+ end
105
+
106
+ def AllocConsole()
107
+ AllocConsole.call != 0
108
+ end
109
+
110
+ def AttachConsole(pid)
111
+ AttachConsole.call(pid)
112
+ end
113
+
114
+ def CreateConsoleScreenBuffer(access, mode, sec, flags, data)
115
+ CreateConsoleScreenBuffer.call(access, mode, sec, flags, data)
116
+ end
117
+
118
+ def FillConsoleOutputAttribute(handle, attribute, length, coord, num)
119
+ FillConsoleOutputAttribute.call(handle, attribute, length, coord, num) != 0
120
+ end
121
+
122
+ def FlushConsoleInputBuffer(handle)
123
+ FlushConsoleInputBuffer.call(handle) != 0
124
+ end
125
+
126
+ def FreeConsole()
127
+ FreeConsole.call != 0
128
+ end
129
+
130
+ def GenerateConsoleCtrlEvent(ctrl_event, process_group_id)
131
+ GenerateConsoleCtrlEvent.call(ctrl_event, process_group_id) != 0
132
+ end
133
+
134
+ def GetConsoleAliases(buffer, buffer_length, exe_name)
135
+ GetConsoleAliases.call(buffer, buffer_length, exe_name)
136
+ end
137
+
138
+ def GetConsoleAliasesLength(exe_name)
139
+ GetConsoleAliasesLength.call(exe_name)
140
+ end
141
+
142
+ def GetConsoleAliasExes(buffer, buffer_length)
143
+ GetConsoleAliasExes.call(buffer, buffer_length)
144
+ end
145
+
146
+ def GetConsoleAliasExesLength()
147
+ GetConsoleAliasExesLength.call
148
+ end
149
+
150
+ def GetConsoleCP()
151
+ GetConsoleCP.call
152
+ end
153
+
154
+ def GetConsoleCursorInfo(handle, cursor_info_ptr)
155
+ GetConsoleCursorInfo.call(handle, cursor_info_ptr)
156
+ end
157
+
158
+ # The docs say this returns a BOOL, but really it's a DWORD
159
+ def GetConsoleDisplayMode(flags)
160
+ GetConsoleDisplayMode.call(flags)
161
+ end
162
+
163
+ def GetConsoleFontSize(handle, font)
164
+ GetConsoleFontSize.call(handle, font)
165
+ end
166
+
167
+ def GetConsoleMode(handle, mode)
168
+ GetConsoleMode.call(handle, mode) != 0
169
+ end
170
+
171
+ def GetConsoleOutputCP()
172
+ GetConsoleOutputCP.call
173
+ end
174
+
175
+ def GetConsoleProcessList(proc_list, proc_count)
176
+ GetConsoleProcessList.call(proc_list, proc_count)
177
+ end
178
+
179
+ def GetConsoleScreenBufferInfo(handle, buf_info)
180
+ GetConsoleScreenBufferInfo.call(handle, buf_info) != 0
181
+ end
182
+
183
+ def GetConsoleSelectionInfo(info_struct)
184
+ GetConsoleSelectionInfo.call(info_struct) != 0
185
+ end
186
+
187
+ def GetConsoleTitle(title, size)
188
+ GetConsoleTitle.call(title, size)
189
+ end
190
+
191
+ def GetConsoleWindow()
192
+ GetConsoleWindow.call
193
+ end
194
+
195
+ def GetCurrentConsoleFont(handle, max_window, current_font_struct)
196
+ GetCurrentConsoleFont.call(handle, max_window, current_font_struct)
197
+ end
198
+
199
+ def GetLargestConsoleWindowSize(handle)
200
+ GetLargestConsoleWindowSize.call(handle)
201
+ end
202
+
203
+ def GetNumberOfConsoleInputEvents(handle, num_events)
204
+ GetNumberOfConsoleInputEvents.call(handle, num_events)
205
+ end
206
+
207
+ def GetNumberOfConsoleMouseButtons(num_mouse_buttons)
208
+ GetNumberOfConsoleMouseButtons.call(num_mouse_buttons)
209
+ end
210
+
211
+ def GetStdHandle(std_handle)
212
+ GetStdHandle.call(std_handle)
213
+ end
214
+
215
+ def PeekConsoleInput(handle, buffer, length, num_events)
216
+ PeekConsoleInput.call(handle, buffer, length, num_events) != 0
217
+ end
218
+
219
+ def ReadConsole(handle, buffer, num_to_read, num_read, res = 0)
220
+ ReadConsole.call(handle, buffer, num_to_read, num_read, res) != 0
221
+ end
222
+
223
+ def ReadConsoleInput(handle, buffer, length, num_read)
224
+ ReadConsoleInput.call(handle, buffer, length, num_read) != 0
225
+ end
226
+
227
+ def ReadConsoleOutput(handle, buffer, buf_size, buf_coord, reg)
228
+ ReadConsoleOutput.call(handle, buffer, buf_size, buf_coord, reg) != 0
229
+ end
230
+
231
+ def ReadConsoleOutputAttribute(handle, attrib, len, coord, num_read)
232
+ ReadConsoleOutputAttribute.call(handle, attrib, len, coord, num_read) != 0
233
+ end
234
+
235
+ def ReadConsoleOutputCharacter(handle, char, length, coord, num_read)
236
+ ReadConsoleOutputCharacter.call(handle, char, length, coord, num_read) != 0
237
+ end
238
+
239
+ def ScrollConsoleScreenBuffer(handle, scroll, clip, coord, fill)
240
+ ScrollConsoleScreenBuffer.call(handle, scroll, clip, coord, fill) != 0
241
+ end
242
+
243
+ def SetConsoleActiveScreenBuffer(handle)
244
+ SetConsoleActiveScreenBuffer.call(handle) != 0
245
+ end
246
+
247
+ def SetConsoleCommandHistoryMode(flags)
248
+ SetConsoleCommandHistoryMode.call(flags) != 0
249
+ end
250
+
251
+ def SetConsoleCP(code_page_id)
252
+ SetConsoleCP.call(code_page_id) != 0
253
+ end
254
+
255
+ def SetConsoleCtrlHandler(handler, add)
256
+ SetConsoleCtrlHandler.call(handler, add) != 0
257
+ end
258
+
259
+ def SetConsoleCursorInfo(handle, cursor)
260
+ SetConsoleCursorInfo.call(handle, cursor) != 0
261
+ end
262
+
263
+ def SetConsoleCursorPosition(handle, coord)
264
+ SetConsoleCursorPosition.call(handle, coord) != 0
265
+ end
266
+
267
+ def SetConsoleDisplayMode(handle, flags, coord)
268
+ SetConsoleDisplayMode.call(handle, flags, coord) != 0
269
+ end
270
+
271
+ def SetConsoleHistoryInfo(info)
272
+ SetConsoleHistoryInfo.call(info) != 0
273
+ end
274
+
275
+ def SetConsoleMode(handle, mode)
276
+ SetConsoleMode.call(handle, mode) != 0
277
+ end
278
+
279
+ def SetConsoleOutputCP(code_page_id)
280
+ SetConsoleOutputCP.call(code_page_id) != 0
281
+ end
282
+
283
+ def SetConsoleScreenBufferSize(handle, size)
284
+ SetConsoleScreenBufferSize.call(handle, size) != 0
285
+ end
286
+
287
+ def SetConsoleTextAttribute(handle, attribute)
288
+ SetConsoleTextAttribute.call(handle, attribute) != 0
289
+ end
290
+
291
+ def SetConsoleTitle(title)
292
+ SetConsoleTitle.call(title) != 0
293
+ end
294
+
295
+ def SetConsoleWindowInfo(handle, absolute, window)
296
+ SetConsoleWindowInfo.call(handle, absolute, window) != 0
297
+ end
298
+
299
+ def SetStdHandle(std_handle, handle)
300
+ SetStdHandle.call(std_handle, handle) != 0
301
+ end
302
+
303
+ def WriteConsole(handle, buffer, num_to_write, num_written, res = 0)
304
+ WriteConsole.call(handle, buffer, num_to_write, num_written, res) != 0
305
+ end
306
+
307
+ def WriteConsoleInput(handle, buffer, length, num_events)
308
+ WriteConsoleInput.call(handle, buffer, length, num_events) != 0
309
+ end
310
+
311
+ def WriteConsoleOutput(handle, buffer, buf_size, coord, region)
312
+ WriteConsoleOutput.call(handle, buffer, buf_size, coord, region) != 0
313
+ end
314
+
315
+ def WriteConsoleOutputAttribute(handle, attrib, length, coord, num)
316
+ WriteConsoleOutputAttribute.call(handle, attrib, length, coord, num) != 0
317
+ end
318
+
319
+ def WriteConsoleOutputCharacter(handle, char, length, coord, num)
320
+ WriteConsoleOutputCharacter.call(handle, char, length, coord, num) != 0
321
+ end
322
+ end
323
+ end
@@ -1,72 +1,3 @@
1
- #####################################################################
2
- # device_io.rb
3
- #
4
- # Defines the following functions:
5
- #
6
- # DeviceIoControl()
7
- #
8
- # Defines the following constants:
9
- #
10
- # FILE_DEVICE_BEEP = 0x00000001
11
- # FILE_DEVICE_CD_ROM = 0x00000002
12
- # FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003
13
- # FILE_DEVICE_CONTROLLER = 0x00000004
14
- # FILE_DEVICE_DATALINK = 0x00000005
15
- # FILE_DEVICE_DFS = 0x00000006
16
- # FILE_DEVICE_DISK = 0x00000007
17
- # FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008
18
- # FILE_DEVICE_FILE_SYSTEM = 0x00000009
19
- # FILE_DEVICE_INPORT_PORT = 0x0000000a
20
- # FILE_DEVICE_KEYBOARD = 0x0000000b
21
- # FILE_DEVICE_MAILSLOT = 0x0000000c
22
- # FILE_DEVICE_MIDI_IN = 0x0000000d
23
- # FILE_DEVICE_MIDI_OUT = 0x0000000e
24
- # FILE_DEVICE_MOUSE = 0x0000000f
25
- # FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010
26
- # FILE_DEVICE_NAMED_PIPE = 0x00000011
27
- # FILE_DEVICE_NETWORK = 0x00000012
28
- # FILE_DEVICE_NETWORK_BROWSER = 0x00000013
29
- # FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
30
- # FILE_DEVICE_NULL = 0x00000015
31
- # FILE_DEVICE_PARALLEL_PORT = 0x00000016
32
- # FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017
33
- # FILE_DEVICE_PRINTER = 0x00000018
34
- # FILE_DEVICE_SCANNER = 0x00000019
35
- # FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001a
36
- # FILE_DEVICE_SERIAL_PORT = 0x0000001b
37
- # FILE_DEVICE_SCREEN = 0x0000001c
38
- # FILE_DEVICE_SOUND = 0x0000001d
39
- # FILE_DEVICE_STREAMS = 0x0000001e
40
- # FILE_DEVICE_TAPE = 0x0000001f
41
- # FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020
42
- # FILE_DEVICE_TRANSPORT = 0x00000021
43
- # FILE_DEVICE_UNKNOWN = 0x00000022
44
- # FILE_DEVICE_VIDEO = 0x00000023
45
- # FILE_DEVICE_VIRTUAL_DISK = 0x00000024
46
- # FILE_DEVICE_WAVE_IN = 0x00000025
47
- # FILE_DEVICE_WAVE_OUT = 0x00000026
48
- # FILE_DEVICE_8042_PORT = 0x00000027
49
- # FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028
50
- # FILE_DEVICE_BATTERY = 0x00000029
51
- # FILE_DEVICE_BUS_EXTENDER = 0x0000002a
52
- # FILE_DEVICE_MODEM = 0x0000002b
53
- # FILE_DEVICE_VDM = 0x0000002c
54
- # FILE_DEVICE_MASS_STORAGE = 0x0000002d
55
- # FILE_DEVICE_SMB = 0x0000002e
56
- # FILE_DEVICE_KS = 0x0000002f
57
- # FILE_DEVICE_CHANGER = 0x00000030
58
- # FILE_DEVICE_SMARTCARD = 0x00000031
59
- # FILE_DEVICE_ACPI = 0x00000032
60
- # FILE_DEVICE_DVD = 0x00000033
61
- # FILE_DEVICE_FULLSCREEN_VIDEO = 0x00000034
62
- # FILE_DEVICE_DFS_FILE_SYSTEM = 0x00000035
63
- # FILE_DEVICE_DFS_VOLUME = 0x00000036
64
- # FILE_DEVICE_SERENUM = 0x00000037
65
- # FILE_DEVICE_TERMSRV = 0x00000038
66
- # FILE_DEVICE_KSEC = 0x00000039
67
- # FILE_DEVICE_FIPS = 0x0000003A
68
- # FILE_DEVICE_INFINIBAND = 0x0000003B
69
- #####################################################################
70
1
  require 'Win32API'
71
2
 
72
3
  module Windows
@@ -0,0 +1,51 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Directory
5
+ CreateDirectory = Win32API.new('kernel32', 'CreateDirectory', 'PP', 'I')
6
+ CreateDirectoryEx = Win32API.new('kernel32', 'CreateDirectoryEx', 'PPP', 'I')
7
+ FindCloseChangeNotification = Win32API.new('kernel32', 'FindCloseChangeNotification', 'L', 'I')
8
+ FindFirstChangeNotification = Win32API.new('kernel32', 'FindFirstChangeNotification', 'PIL', 'L')
9
+ FindNextChangeNotification = Win32API.new('kernel32', 'FindFirstChangeNotification', 'PIL', 'I')
10
+ GetCurrentDirectory = Win32API.new('kernel32', 'GetCurrentDirectory', 'LP', 'L')
11
+ ReadDirectoryChangesW = Win32API.new('kernel32', 'ReadDirectoryChangesW', 'LPLILPPP', 'I')
12
+ RemoveDirectory = Win32API.new('kernel32', 'RemoveDirectory', 'P', 'I')
13
+ SetCurrentDirectory = Win32API.new('kernel32', 'SetCurrentDirectory', 'P', 'I')
14
+
15
+ def CreateDirectory(path, attributes)
16
+ CreateDirectory.call(path, attributes) != 0
17
+ end
18
+
19
+ def CreateDirectoryEx(template, new, attributes)
20
+ CreateDirectoryEx.call(template, new, attributes) != 0
21
+ end
22
+
23
+ def FindCloseChangeNotification(handle)
24
+ FindCloseChangeNotification.call(handle) != 0
25
+ end
26
+
27
+ def FindFirstChangeNotification(path, subtree, filter)
28
+ FindFirstChangeNotification.call(path, subtree, filter)
29
+ end
30
+
31
+ def FindNextChangeNotification(handle)
32
+ FindNextChangeNotification.call(handle) != 0
33
+ end
34
+
35
+ def GetCurrentDirectory(buf_len, buf)
36
+ GetCurrentDirectory.call(buf_len, buf)
37
+ end
38
+
39
+ def ReadDirectoryChangesW(handle, buf, buf_len, subtree, filter, bytes, overlapped, routine)
40
+ ReadDirectoryChangesW.call(handle, buf, buf_len, subtree, filter, bytes, overlapped, routine) != 0
41
+ end
42
+
43
+ def RemoveDirectory(path)
44
+ RemoveDirectory.call(path) != 0
45
+ end
46
+
47
+ def SetCurrentDirectory(path)
48
+ SetCurrentDirectory.call(path) != 0
49
+ end
50
+ end
51
+ end
data/lib/windows/error.rb CHANGED
@@ -1,37 +1,14 @@
1
1
  ############################################################################
2
2
  # error.rb
3
3
  #
4
- # Includes the following functions:
5
- #
6
- # GetLastError()
7
- # FormatError()
8
- # SetErrorMode()
9
- # SetLastError()
10
- # SetLastErrorex()
11
- #
12
- # Defines the following constants:
13
- #
14
- # FORMAT_MESSAGE_ALLOCATE_BUFFER
15
- # FORMAT_MESSAGE_IGNORE_INSERTS
16
- # FORMAT_MESSAGE_FROM_STRING
17
- # FORMAT_MESSAGE_FROM_HMODULE
18
- # FORMAT_MESSAGE_FROM_SYSTEM
19
- # FORMAT_MESSAGE_ARGUMENT_ARRAY
20
- # FORMAT_MESSAGE_MAX_WIDTH_MASK
21
- #
22
- # SEM_FAILCRITICALERRORS
23
- # SEM_NOALIGNMENTFAULTEXCEPT
24
- # SEM_NOGPFAULTERRORBOX
25
- # SEM_NOOPENFILEERRORBOX
26
- #
27
- # All of the error codes in error.h.
4
+ # Includes all of the error codes in error.h and some from winerror.h.
28
5
  #
29
6
  # Adds the following convenience methods:
30
7
  #
31
8
  # get_last_error - Returns a human readable string for the error returned
32
9
  # by the GetLastError() function.
33
10
  ############################################################################
34
- require "Win32API"
11
+ require 'Win32API'
35
12
 
36
13
  module Windows
37
14
  module Error
@@ -285,6 +262,10 @@ module Windows
285
262
  TC_HARDERR = 1
286
263
  TC_GP_TRAP = 2
287
264
  TC_SIGNAL = 3
265
+
266
+ # From WinError.h
267
+ ERROR_INVALID_FLAGS = 4100 # 1004L
268
+ ERROR_NO_UNICODE_TRANSLATION = 4371
288
269
 
289
270
  GetLastError = Win32API.new('kernel32', 'GetLastError', 'V', 'L')
290
271
  SetLastError = Win32API.new('kernel32', 'GetLastError', 'L', 'V')
data/lib/windows/file.rb CHANGED
@@ -1,37 +1,3 @@
1
- ######################################################################
2
- # file.rb
3
- #
4
- # Defines the following functions:
5
- #
6
- # CopyFile()
7
- # CopyFileEx()
8
- # CreateFile()
9
- # CreateHardLink()
10
- # DecryptFile()
11
- # DeleteFile()
12
- # EncryptFile()
13
- # GetFileAttributes()
14
- # GetFileAttributesEx()
15
- # GetFileSize()
16
- # GetFileSizeEx()
17
- # GetFileType()
18
- # GetLongPathName()
19
- # GetShortPathName()
20
- # LockFile()
21
- # LockFileEx()
22
- # ReadFile()
23
- # ReadFileEx()
24
- # ReOpenFile()
25
- # SetFileAttributes()
26
- # UnlockFile()
27
- # UnlockFileEx()
28
- # WriteFile()
29
- # WriteFileEx()
30
- #
31
- # TODO:
32
- #
33
- # Add remaining file functions.
34
- ######################################################################
35
1
  require 'Win32API'
36
2
 
37
3
  module Windows
@@ -0,0 +1,71 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Library
5
+ DLL_PROCESS_DETACH = 0
6
+ DLL_PROCESS_ATTACH = 1
7
+ DLL_THREAD_ATTACH = 2
8
+ DLL_THREAD_DETACH = 3
9
+
10
+ GET_MODULE_HANDLE_EX_FLAG_PIN = 1
11
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
12
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
13
+
14
+ DisableThreadLibraryCalls = Win32API.new('kernel32', 'DisableThreadLibraryCalls', 'L', 'I')
15
+ FreeLibrary = Win32API.new('kernel32', 'FreeLibrary', 'L', 'I')
16
+ FreeLibraryAndExitThread = Win32API.new('kernel32', 'FreeLibraryAndExitThread', 'LL', 'V')
17
+ GetDllDirectory = Win32API.new('kernel32', 'GetDllDirectory', 'LP', 'L')
18
+ GetModuleFileName = Win32API.new('kernel32', 'GetModuleFileName', 'LPL', 'L')
19
+ GetModuleHandle = Win32API.new('kernel32', 'GetModuleHandle', 'P', 'L')
20
+ GetModuleHandleEx = Win32API.new('kernel32', 'GetModuleHandleEx', 'LPP', 'I')
21
+ GetProcAddress = Win32API.new('kernel32', 'GetProcAddress', 'LP', 'L')
22
+ LoadLibrary = Win32API.new('kernel32', 'LoadLibrary', 'P', 'L')
23
+ LoadLibraryEx = Win32API.new('kernel32', 'LoadLibraryEx', 'PLL', 'L')
24
+ LoadModule = Win32API.new('kernel32', 'LoadModule', 'PP', 'L')
25
+ SetDllDirectory = Win32API.new('kernel32', 'SetDllDirectory', 'P', 'I')
26
+
27
+ def DisableThreadLibraryCalls(hmodule)
28
+ DisableThreadLibraryCalls.call(hmodule) != 0
29
+ end
30
+
31
+ def FreeLibrary(hmodule)
32
+ FreeLibrary.call(hmodule) != 0
33
+ end
34
+
35
+ def GetDllDirectory(length, buffer)
36
+ GetDllDirectory.call(length, buffer)
37
+ end
38
+
39
+ def GetModuleFileName(hmodule, file, size)
40
+ GetModuleFileName.call(hmodule, file, size)
41
+ end
42
+
43
+ def GetModuleHandle(module_name)
44
+ GetModuleHandle.call(module_name)
45
+ end
46
+
47
+ def GetModuleHandleEx(flags, module_name, hmodule)
48
+ GetModuleHandleEx.call(flags, module_name, hmodule)
49
+ end
50
+
51
+ def GetProcAddress(hmodule, proc_name)
52
+ GetProcAddress.call(hmodule, proc_name)
53
+ end
54
+
55
+ def LoadLibrary(library)
56
+ LoadLibrary.call(library)
57
+ end
58
+
59
+ def LoadLibraryEx(library, file, flags)
60
+ LoadLibraryEx.call(library, file, flags)
61
+ end
62
+
63
+ def LoadModule(hmodule, param_block)
64
+ LoadModule.call(hmodule, param_block)
65
+ end
66
+
67
+ def SetDllDirectory(path)
68
+ SetDllDirectory.call(path)
69
+ end
70
+ end
71
+ end