windows-pr 0.5.3 → 0.5.4

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.5.4 - 8-Sep-2006
2
+ * Added the Windows::NetworkManagement module, which contains methods like
3
+ NetUserAdd(), etc.
4
+ * Fixed bugs in SetLastError and SetLastErrorEx declarations.
5
+ * Finer grained method wrapping/checking for the Windows::Library module.
6
+ * Finer grained method wrapping/checking for the Windows::Console module.
7
+ * Added a test case for the Windows::Library module.
8
+ * Added the LOCKFILE_EXCLUSIVE_LOCK and LOCKFILE_FAIL_IMMEDIATELY constants
9
+ to the Windows::File module.
10
+
1
11
  = 0.5.3 - 10-Aug-2006
2
12
  * Added wide character functions to the EventLog module.
3
13
  * Added a test suite for the EventLog module.
data/README CHANGED
@@ -33,17 +33,17 @@
33
33
  then the wrapper method is lower case as well. For example, instead of
34
34
  doing 'Memcpy.call(dest, src, size)' you can do 'memcpy(dest, src, size)'.
35
35
 
36
- Remember boys and girls, if you write PathIsRoot, you're referring to
37
- the constant. If you write PathIsRoot(), you're calling the wrapper
36
+ Remember boys and girls, if you write 'PathIsRoot', you're referring to
37
+ the constant. If you write 'PathIsRoot()', you're calling the wrapper
38
38
  method.
39
39
 
40
40
  Boolean methods automatically perform a check for success or failure. So,
41
41
  instead of having to do something like 'if PathIsRoot(path) > 0' you can
42
42
  just do 'if PathIsRoot(path)'.
43
43
 
44
- Files contain related functions, by topic. For example, the clipboard.rb
45
- file contains clipboard related functions, such as CloseClipboard(), as
46
- well as constants such as CF_TEXT, CF_BITMAP, etc.
44
+ Source files contain related functions, by topic. For example, the
45
+ clipboard.rb file contains clipboard related functions, such as
46
+ CloseClipboard(), as well as constants such as CF_TEXT, CF_BITMAP, etc.
47
47
 
48
48
  == Wide character functions
49
49
  I decided that the $KCODE handling was a bad idea, so most of the $KCODE
@@ -55,6 +55,18 @@
55
55
  In the future I'll add the wide character functions explicitly. I haven't
56
56
  added many yet (as of 29-Jul-2006) but I plan on adding as many as I can
57
57
  as time permits.
58
+
59
+ == Platform specific functions
60
+ Not all functions are defined on all platforms. For example, the
61
+ AttachConsole() function is only defined on Windows XP and later. If you
62
+ need to conditionally test for its existance, simply use the 'defined?'
63
+ method:
64
+
65
+ if defined? AttachConsole
66
+ # Do something
67
+ else
68
+ # Do something else
69
+ end
58
70
 
59
71
  == Where are the tests, dude?
60
72
  While I've made some effort to test these functions, there are simply too
@@ -93,7 +105,9 @@
93
105
  http://www.rubyforge.org/projects/win32utils.
94
106
 
95
107
  The only real bugs you could find are either bad prototype declarations
96
- or bad constant values. But, please report either.
108
+ or bad constant values. Sometimes I forget to wrap functions properly
109
+ that may not be defined on older Windows platforms. But, please report
110
+ any of these issues on the project page should you stumble into them.
97
111
 
98
112
  == Known Issues
99
113
  In some cases the MSDN docs are wrong, and we have to learn it the hard
@@ -8,7 +8,7 @@ Void: 'V'
8
8
  BOOL => 'I'
9
9
  DWORD => 'L'
10
10
  HANDLE => 'L'
11
- LPDWORD => 'P'
11
+ LPDWORD => 'P' (or 'L')
12
12
  LPTSTR => 'P'
13
13
  UINT => 'I'
14
14
  VOID => 'V'
data/install.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "ftools"
2
+ require "rbconfig"
3
+ include Config
4
+
5
+ sitelibdir = CONFIG["sitelibdir"]
6
+ installdir = sitelibdir + "/windows"
7
+ installdir2 = sitelibdir + "/windows/msvcrt"
8
+
9
+ Dir.mkdir(installdir) unless File.exists?(installdir)
10
+ Dir.mkdir(installdir2) unless File.exists?(installdir2)
11
+
12
+ Dir["lib/windows/*.rb"].each{ |file|
13
+ File.copy(file, installdir, true)
14
+ }
15
+
16
+ Dir["lib/windows/msvcrt/*.rb"].each{ |file|
17
+ File.copy(file, installdir2, true)
18
+ }
@@ -43,8 +43,7 @@ module Windows
43
43
  CONSOLE_FULLSCREEN_HARDWARE = 2
44
44
 
45
45
  AddConsoleAlias = Win32API.new('kernel32', 'AddConsoleAlias', 'PPP', 'I')
46
- AllocConsole = Win32API.new('kernel32', 'AllocConsole', 'V', 'I')
47
- AttachConsole = Win32API.new('kernel32', 'AttachConsole', 'L', 'I')
46
+ AllocConsole = Win32API.new('kernel32', 'AllocConsole', 'V', 'I')
48
47
  CreateConsoleScreenBuffer = Win32API.new('kernel32', 'CreateConsoleScreenBuffer', 'LLPLP', 'L')
49
48
  FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', 'LILLP', 'I')
50
49
  FillConsoleOutputCharacter = Win32API.new('kernel32', 'FillConsoleOutputCharacter', 'LILLP', 'I')
@@ -57,17 +56,11 @@ module Windows
57
56
  GetConsoleAliasExes = Win32API.new('kernel32', 'GetConsoleAliasExes', 'PL', 'L')
58
57
  GetConsoleAliasExesLength = Win32API.new('kernel32', 'GetConsoleAliasExesLength', 'V', 'L')
59
58
  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')
59
+ GetConsoleCursorInfo = Win32API.new('kernel32', 'GetConsoleCursorInfo', 'LP', 'I')
63
60
  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')
61
+ GetConsoleOutputCP = Win32API.new('kernel32', 'GetConsoleOutputCP', 'V', 'I')
62
+ GetConsoleScreenBufferInfo = Win32API.new('kernel32', 'GetConsoleScreenBufferInfo', 'LP', 'I')
63
+ GetConsoleTitle = Win32API.new('kernel32', 'GetConsoleTitle', 'PL', 'L')
71
64
  GetLargestConsoleWindowSize = Win32API.new('kernel32', 'GetLargestConsoleWindowSize', 'L', 'L')
72
65
  GetNumberOfConsoleInputEvents = Win32API.new('kernel32', 'GetNumberOfConsoleInputEvents', 'LP', 'I')
73
66
  GetNumberOfConsoleMouseButtons = Win32API.new('kernel32', 'GetNumberOfConsoleMouseButtons', 'L', 'I')
@@ -84,8 +77,7 @@ module Windows
84
77
  SetConsoleCP = Win32API.new('kernel32', 'SetConsoleCP', 'L', 'I')
85
78
  SetConsoleCtrlHandler = Win32API.new('kernel32', 'SetConsoleCtrlHandler', 'PI', 'I')
86
79
  SetConsoleCursorInfo = Win32API.new('kernel32', 'SetConsoleCursorInfo', 'LP', 'I')
87
- SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', 'LP', 'I')
88
- SetConsoleDisplayMode = Win32API.new('kernel32', 'SetConsoleDisplayMode', 'LLP', 'I')
80
+ SetConsoleCursorPosition = Win32API.new('kernel32', 'SetConsoleCursorPosition', 'LP', 'I')
89
81
  SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', 'LL', 'I')
90
82
  SetConsoleOutputCP = Win32API.new('kernel32', 'SetConsoleOutputCP', 'I', 'I')
91
83
  SetConsoleScreenBufferSize = Win32API.new('kernel32', 'SetConsoleScreenBufferSize', 'LL', 'I')
@@ -98,6 +90,28 @@ module Windows
98
90
  WriteConsoleOutput = Win32API.new('kernel32', 'WriteConsoleOutput', 'LPLLP', 'I')
99
91
  WriteConsoleOutputAttribute = Win32API.new('kernel32', 'WriteConsoleOutputAttribute', 'LPLLP', 'I')
100
92
  WriteConsoleOutputCharacter = Win32API.new('kernel32', 'WriteConsoleOutputCharacter', 'LPLLP', 'I')
93
+
94
+ # Windows XP or later
95
+ begin
96
+ AttachConsole = Win32API.new('kernel32', 'AttachConsole', 'L', 'I')
97
+ GetConsoleDisplayMode = Win32API.new('kernel32', 'GetConsoleDisplayMode', 'P', 'L')
98
+ GetConsoleFontSize = Win32API.new('kernel32', 'GetConsoleFontSize', 'LL', 'L')
99
+ GetConsoleProcessList = Win32API.new('kernel32', 'GetConsoleProcessList', 'PL', 'L')
100
+ GetConsoleSelectionInfo = Win32API.new('kernel32', 'GetConsoleSelectionInfo', 'P', 'I')
101
+ GetCurrentConsoleFont = Win32API.new('kernel32', 'GetCurrentConsoleFont' , 'LIP', 'I')
102
+ SetConsoleDisplayMode = Win32API.new('kernel32', 'SetConsoleDisplayMode', 'LLP', 'I')
103
+ rescue Exception
104
+ # Do nothing - not supported on current platform. It's up to you to
105
+ # check for the existence of the constant in your code.
106
+ end
107
+
108
+ # Windows 2000 or later
109
+ begin
110
+ GetConsoleWindow = Win32API.new('kernel32', 'GetConsoleWindow', 'V', 'L')
111
+ rescue Exception
112
+ # Do nothing - not supported on current platform. It's up to you to
113
+ # check for the existence of the constant in your code.
114
+ end
101
115
 
102
116
  def AddConsoleAlias(source, target, exe)
103
117
  AddConsoleAlias.call(source, target, exe) != 0
@@ -107,10 +121,6 @@ module Windows
107
121
  AllocConsole.call != 0
108
122
  end
109
123
 
110
- def AttachConsole(pid)
111
- AttachConsole.call(pid)
112
- end
113
-
114
124
  def CreateConsoleScreenBuffer(access, mode, sec, flags, data)
115
125
  CreateConsoleScreenBuffer.call(access, mode, sec, flags, data)
116
126
  end
@@ -155,15 +165,6 @@ module Windows
155
165
  GetConsoleCursorInfo.call(handle, cursor_info_ptr)
156
166
  end
157
167
 
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
168
  def GetConsoleMode(handle, mode)
168
169
  GetConsoleMode.call(handle, mode) != 0
169
170
  end
@@ -172,30 +173,14 @@ module Windows
172
173
  GetConsoleOutputCP.call
173
174
  end
174
175
 
175
- def GetConsoleProcessList(proc_list, proc_count)
176
- GetConsoleProcessList.call(proc_list, proc_count)
177
- end
178
-
179
176
  def GetConsoleScreenBufferInfo(handle, buf_info)
180
177
  GetConsoleScreenBufferInfo.call(handle, buf_info) != 0
181
178
  end
182
179
 
183
- def GetConsoleSelectionInfo(info_struct)
184
- GetConsoleSelectionInfo.call(info_struct) != 0
185
- end
186
-
187
180
  def GetConsoleTitle(title, size)
188
181
  GetConsoleTitle.call(title, size)
189
182
  end
190
183
 
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
184
  def GetLargestConsoleWindowSize(handle)
200
185
  GetLargestConsoleWindowSize.call(handle)
201
186
  end
@@ -264,10 +249,6 @@ module Windows
264
249
  SetConsoleCursorPosition.call(handle, coord) != 0
265
250
  end
266
251
 
267
- def SetConsoleDisplayMode(handle, flags, coord)
268
- SetConsoleDisplayMode.call(handle, flags, coord) != 0
269
- end
270
-
271
252
  def SetConsoleHistoryInfo(info)
272
253
  SetConsoleHistoryInfo.call(info) != 0
273
254
  end
@@ -319,5 +300,46 @@ module Windows
319
300
  def WriteConsoleOutputCharacter(handle, char, length, coord, num)
320
301
  WriteConsoleOutputCharacter.call(handle, char, length, coord, num) != 0
321
302
  end
303
+
304
+ begin
305
+ def AttachConsole(pid)
306
+ AttachConsole.call(pid)
307
+ end
308
+
309
+ # The docs say this returns a BOOL, but really it's a DWORD
310
+ def GetConsoleDisplayMode(flags)
311
+ GetConsoleDisplayMode.call(flags)
312
+ end
313
+
314
+ def GetConsoleFontSize(handle, font)
315
+ GetConsoleFontSize.call(handle, font)
316
+ end
317
+
318
+ def GetConsoleProcessList(proc_list, proc_count)
319
+ GetConsoleProcessList.call(proc_list, proc_count)
320
+ end
321
+
322
+ def GetConsoleSelectionInfo(info_struct)
323
+ GetConsoleSelectionInfo.call(info_struct) != 0
324
+ end
325
+
326
+ def GetCurrentConsoleFont(handle, max_window, current_font_struct)
327
+ GetCurrentConsoleFont.call(handle, max_window, current_font_struct)
328
+ end
329
+
330
+ def SetConsoleDisplayMode(handle, flags, coord)
331
+ SetConsoleDisplayMode.call(handle, flags, coord) != 0
332
+ end
333
+ rescue Exception
334
+ # Windows XP or later
335
+ end
336
+
337
+ begin
338
+ def GetConsoleWindow()
339
+ GetConsoleWindow.call
340
+ end
341
+ rescue Exception
342
+ # Windows 2000 or later
343
+ end
322
344
  end
323
345
  end
data/lib/windows/error.rb CHANGED
@@ -270,12 +270,16 @@ module Windows
270
270
  ERROR_NO_UNICODE_TRANSLATION = 4371
271
271
 
272
272
  GetLastError = Win32API.new('kernel32', 'GetLastError', 'V', 'L')
273
- SetLastError = Win32API.new('kernel32', 'GetLastError', 'L', 'V')
274
- SetLastErrorEx = Win32API.new('kernel32', 'GetLastError', 'LL', 'V')
273
+ SetLastError = Win32API.new('kernel32', 'SetLastError', 'L', 'V')
275
274
  SetErrorMode = Win32API.new('kernel32', 'SetErrorMode', 'I', 'I')
276
275
  FormatMessage = Win32API.new('kernel32', 'FormatMessage', 'LLLLPLP', 'L')
277
276
  FormatMessageW = Win32API.new('kernel32', 'FormatMessageW', 'LLLLPLP', 'L')
278
277
 
278
+ begin
279
+ SetLastErrorEx = Win32API.new('kernel32', 'SetLastErrorEx', 'LL', 'V')
280
+ rescue Exception
281
+ end
282
+
279
283
  def GetLastError
280
284
  GetLastError.call
281
285
  end
@@ -284,10 +288,6 @@ module Windows
284
288
  SetLastError.call(error)
285
289
  end
286
290
 
287
- def SetLastErrorEx(error, type=0)
288
- SetLastErrorEx.call(error, type)
289
- end
290
-
291
291
  def SetErrorMode(mode)
292
292
  SetErrorMode.call(mode)
293
293
  end
@@ -300,14 +300,22 @@ module Windows
300
300
  FormatMessageW.call(flags, src, msg_id, lang_id, buf, size, args)
301
301
  end
302
302
 
303
+ begin
304
+ def SetLastErrorEx(error, type=0)
305
+ SetLastErrorEx.call(error, type)
306
+ end
307
+ rescue Exception
308
+ # VC++ 7.0 or later
309
+ end
310
+
303
311
  # Convenience method that wraps FormatMessage with some sane defaults and
304
312
  # returns a human readable string.
305
313
  #
306
314
  def get_last_error(err_num = GetLastError.call)
307
315
  buf = 0.chr * 260
308
316
  flags = FORMAT_MESSAGE_FROM_SYSTEM + FORMAT_MESSAGE_ARGUMENT_ARRAY
309
- FormatMessage.call(flags, 0, err_num, 0, buf, buf.size, 0)
310
- buf.split(0.chr).first.chomp
317
+ FormatMessage.call(flags, 0, err_num, 0, buf, buf.size, 0)
318
+ buf.split(0.chr).first.chomp rescue 'Unknown error'
311
319
  end
312
320
  end
313
321
  end
data/lib/windows/file.rb CHANGED
@@ -137,25 +137,6 @@ module Windows
137
137
  OPEN_EXISTING = 3
138
138
  OPEN_ALWAYS = 4
139
139
  TRUNCATE_EXISTING = 5
140
-
141
- # Page file access
142
- PAGE_NOACCESS = 0x01
143
- PAGE_READONLY = 0x02
144
- PAGE_READWRITE = 0x04
145
- PAGE_WRITECOPY = 0x08
146
- PAGE_EXECUTE = 0x10
147
- PAGE_EXECUTE_READ = 0x20
148
- PAGE_EXECUTE_READWRITE = 0x40
149
- PAGE_EXECUTE_WRITECOPY = 0x80
150
- PAGE_GUARD = 0x100
151
- PAGE_NOCACHE = 0x200
152
- PAGE_WRITECOMBINE = 0x400
153
- SEC_FILE = 0x800000
154
- SEC_IMAGE = 0x1000000
155
- SEC_VLM = 0x2000000
156
- SEC_RESERVE = 0x4000000
157
- SEC_COMMIT = 0x8000000
158
- SEC_NOCACHE = 0x10000000
159
140
 
160
141
  SECTION_QUERY = 0x0001
161
142
  SECTION_MAP_WRITE = 0x0002
@@ -166,30 +147,24 @@ module Windows
166
147
  SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
167
148
  SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE |
168
149
  SECTION_EXTEND_SIZE
169
-
170
- FILE_MAP_COPY = SECTION_QUERY
171
- FILE_MAP_WRITE = SECTION_MAP_WRITE
172
- FILE_MAP_READ = SECTION_MAP_READ
173
- FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS
174
-
150
+
175
151
  # Errors
176
152
  INVALID_FILE_ATTRIBUTES = -1
177
153
  INVALID_HANDLE_VALUE = -1
178
154
  INVALID_FILE_SIZE = 0xFFFFFFFF
155
+
156
+ # Misc
157
+ LOCKFILE_EXCLUSIVE_LOCK = 0x00000001
158
+ LOCKFILE_FAIL_IMMEDIATELY = 0x00000002
179
159
 
180
160
  CopyFile = Win32API.new('kernel32', 'CopyFile', 'PPI', 'I')
181
161
  CopyFileEx = Win32API.new('kernel32', 'CopyFileEx', 'PPPPPL', 'I')
182
162
  CreateFile = Win32API.new('kernel32', 'CreateFile', 'PLLPLLL', 'L')
183
163
  CreateFileW = Win32API.new('kernel32', 'CreateFileW', 'PLLPLLL', 'L')
184
-
185
- CreateFileMapping = Win32API.new('kernel32', 'CreateFileMapping', 'LPLLLP', 'L')
186
-
187
164
  CreateHardLink = Win32API.new('kernel32', 'CreateHardLink', 'PPP', 'I')
188
165
  DecryptFile = Win32API.new('advapi32', 'DecryptFile', 'PL', 'I')
189
166
  DeleteFile = Win32API.new('kernel32', 'DeleteFile', 'P', 'I')
190
167
  EncryptFile = Win32API.new('advapi32', 'EncryptFile', 'P', 'I')
191
-
192
- FlushViewOfFile = Win32API.new('kernel32', 'FlushViewOfFile', 'PL', 'I')
193
168
 
194
169
  GetBinaryType = Win32API.new('kernel32', 'GetBinaryType', 'PP', 'I')
195
170
  GetFileAttributes = Win32API.new('kernel32', 'GetFileAttributes', 'P', 'L')
@@ -204,11 +179,6 @@ module Windows
204
179
 
205
180
  LockFile = Win32API.new('kernel32', 'LockFile', 'LLLLL', 'I')
206
181
  LockFileEx = Win32API.new('kernel32', 'LockFileEx', 'LLLLLL', 'I')
207
-
208
- MapViewOfFile = Win32API.new('kernel32', 'MapViewOfFile', 'LLLLL', 'L')
209
- MapViewOfFileEx = Win32API.new('kernel32', 'MapViewOfFileEx', 'LLLLLL', 'L')
210
- OpenFileMapping = Win32API.new('kernel32', 'OpenFileMapping', 'LIP', 'L')
211
-
212
182
  ReadFile = Win32API.new('kernel32', 'ReadFile', 'LPLPP', 'I')
213
183
  ReadFileEx = Win32API.new('kernel32', 'ReadFileEx', 'LPLPP', 'I')
214
184
 
@@ -216,9 +186,6 @@ module Windows
216
186
 
217
187
  UnlockFile = Win32API.new('kernel32', 'UnlockFile', 'LLLLL', 'I')
218
188
  UnlockFileEx = Win32API.new('kernel32', 'UnlockFileEx', 'LLLLL', 'I')
219
-
220
- UnmapViewOfFile = Win32API.new('kernel32', 'UnmapViewOfFile', 'P', 'I')
221
-
222
189
  WriteFile = Win32API.new('kernel32', 'WriteFile', 'LPLPP', 'I')
223
190
  WriteFileEx = Win32API.new('kernel32', 'WriteFileEx', 'LPLPP', 'I')
224
191
 
@@ -234,10 +201,6 @@ module Windows
234
201
  CreateFile.call(file, access, share, sec, disp, flags, template)
235
202
  end
236
203
 
237
- def CreateFileMapping(handle, security, protect, high, low, name)
238
- CreateFileMapping.call(handle, security, protect, high, low, name)
239
- end
240
-
241
204
  def CreateHardLink(new_file, old_file, attributes)
242
205
  CreateHardLink.call(new_file, old_file, attributes) > 0
243
206
  end
@@ -253,10 +216,6 @@ module Windows
253
216
  def EncryptFile(file)
254
217
  EncryptFile.call(file) > 0
255
218
  end
256
-
257
- def FlushViewOfFile(address, bytes)
258
- FlushViewOfFile.call(address, bytes) != 0
259
- end
260
219
 
261
220
  def GetBinaryType(file, type)
262
221
  GetBinaryType.call(file, type) > 0
@@ -302,18 +261,6 @@ module Windows
302
261
  LockFileEx.call(handle, flags, res, low, high, overlapped) > 0
303
262
  end
304
263
 
305
- def MapViewOfFile(handle, access, high, low, bytes)
306
- MapViewOfFile.call(handle, access, high, low, bytes)
307
- end
308
-
309
- def MapViewOfFileEx(handle, access, high, low, bytes, address)
310
- MapViewOfFileEx.call(handle, access, high, low, bytes, address)
311
- end
312
-
313
- def OpenFileMapping(access, inherit, name)
314
- OpenFileMapping.call(access, inherit, name)
315
- end
316
-
317
264
  def ReadFile(file, buf, bytes, bytes_read, overlapped)
318
265
  ReadFile.call(file, buf, bytes, bytes_read, overlapped) > 0
319
266
  end
@@ -334,10 +281,6 @@ module Windows
334
281
  UnlockFileEx.call(handle, res, low, high, overlapped) > 0
335
282
  end
336
283
 
337
- def UnmapViewOfFile(address)
338
- UnmapViewOfFile.call(address) != 0
339
- end
340
-
341
284
  def WriteFile(handle, buf, bytes, overlapped)
342
285
  WriteFileEx.call(handle, buf, bytes, overlapped) > 0
343
286
  end
@@ -0,0 +1,59 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module FileMapping
5
+ FILE_MAP_COPY = 0x0001
6
+ FILE_MAP_WRITE = 0x0002
7
+ FILE_MAP_READ = 0x0004
8
+ FILE_MAP_ALL_ACCESS = 983071
9
+
10
+ PAGE_NOACCESS = 0x01
11
+ PAGE_READONLY = 0x02
12
+ PAGE_READWRITE = 0x04
13
+ PAGE_WRITECOPY = 0x08
14
+ PAGE_EXECUTE = 0x10
15
+ PAGE_EXECUTE_READ = 0x20
16
+ PAGE_EXECUTE_READWRITE = 0x40
17
+ PAGE_EXECUTE_WRITECOPY = 0x80
18
+ PAGE_GUARD = 0x100
19
+ PAGE_NOCACHE = 0x200
20
+ PAGE_WRITECOMBINE = 0x400
21
+ SEC_FILE = 0x800000
22
+ SEC_IMAGE = 0x1000000
23
+ SEC_VLM = 0x2000000
24
+ SEC_RESERVE = 0x4000000
25
+ SEC_COMMIT = 0x8000000
26
+ SEC_NOCACHE = 0x10000000
27
+
28
+ CreateFileMapping = Win32API.new('kernel32', 'CreateFileMapping', 'LPLLLP', 'L')
29
+ FlushViewOfFile = Win32API.new('kernel32', 'FlushViewOfFile', 'PL', 'I')
30
+ MapViewOfFile = Win32API.new('kernel32', 'MapViewOfFile', 'LLLLL', 'L')
31
+ MapViewOfFileEx = Win32API.new('kernel32', 'MapViewOfFileEx', 'LLLLLL', 'L')
32
+ OpenFileMapping = Win32API.new('kernel32', 'OpenFileMapping', 'LIP', 'L')
33
+ UnmapViewOfFile = Win32API.new('kernel32', 'UnmapViewOfFile', 'P', 'I')
34
+
35
+ def CreateFileMapping(handle, security, protect, high, low, name)
36
+ CreateFileMapping.call(handle, security, protect, high, low, name)
37
+ end
38
+
39
+ def FlushViewOfFile(address, bytes)
40
+ FlushViewOfFile.call(address, bytes) != 0
41
+ end
42
+
43
+ def MapViewOfFile(handle, access, high, low, bytes)
44
+ MapViewOfFile.call(handle, access, high, low, bytes)
45
+ end
46
+
47
+ def MapViewOfFileEx(handle, access, high, low, bytes, address)
48
+ MapViewOfFileEx.call(handle, access, high, low, bytes, address)
49
+ end
50
+
51
+ def OpenFileMapping(access, inherit, name)
52
+ OpenFileMapping.call(access, inherit, name)
53
+ end
54
+
55
+ def UnmapViewOfFile(address)
56
+ UnmapViewOfFile.call(address) != 0
57
+ end
58
+ end
59
+ end
@@ -18,16 +18,23 @@ module Windows
18
18
 
19
19
  DisableThreadLibraryCalls = Win32API.new('kernel32', 'DisableThreadLibraryCalls', 'L', 'I')
20
20
  FreeLibrary = Win32API.new('kernel32', 'FreeLibrary', 'L', 'I')
21
- FreeLibraryAndExitThread = Win32API.new('kernel32', 'FreeLibraryAndExitThread', 'LL', 'V')
22
- GetDllDirectory = Win32API.new('kernel32', 'GetDllDirectory', 'LP', 'L')
21
+ FreeLibraryAndExitThread = Win32API.new('kernel32', 'FreeLibraryAndExitThread', 'LL', 'V')
23
22
  GetModuleFileName = Win32API.new('kernel32', 'GetModuleFileName', 'LPL', 'L')
24
- GetModuleHandle = Win32API.new('kernel32', 'GetModuleHandle', 'P', 'L')
25
- GetModuleHandleEx = Win32API.new('kernel32', 'GetModuleHandleEx', 'LPP', 'I')
23
+ GetModuleHandle = Win32API.new('kernel32', 'GetModuleHandle', 'P', 'L')
26
24
  GetProcAddress = Win32API.new('kernel32', 'GetProcAddress', 'LP', 'L')
27
25
  LoadLibrary = Win32API.new('kernel32', 'LoadLibrary', 'P', 'L')
28
26
  LoadLibraryEx = Win32API.new('kernel32', 'LoadLibraryEx', 'PLL', 'L')
29
27
  LoadModule = Win32API.new('kernel32', 'LoadModule', 'PP', 'L')
30
- SetDllDirectory = Win32API.new('kernel32', 'SetDllDirectory', 'P', 'I')
28
+
29
+ # Windows XP or later
30
+ begin
31
+ GetDllDirectory = Win32API.new('kernel32', 'GetDllDirectory', 'LP', 'L')
32
+ GetModuleHandleEx = Win32API.new('kernel32', 'GetModuleHandleEx', 'LPP', 'I')
33
+ SetDllDirectory = Win32API.new('kernel32', 'SetDllDirectory', 'P', 'I')
34
+ rescue Exception
35
+ # Do nothing - not supported on current platform. It's up to you to
36
+ # check for the existence of the constant in your code.
37
+ end
31
38
 
32
39
  def DisableThreadLibraryCalls(hmodule)
33
40
  DisableThreadLibraryCalls.call(hmodule) != 0
@@ -37,10 +44,6 @@ module Windows
37
44
  FreeLibrary.call(hmodule) != 0
38
45
  end
39
46
 
40
- def GetDllDirectory(length, buffer)
41
- GetDllDirectory.call(length, buffer)
42
- end
43
-
44
47
  def GetModuleFileName(hmodule, file, size)
45
48
  GetModuleFileName.call(hmodule, file, size)
46
49
  end
@@ -48,11 +51,7 @@ module Windows
48
51
  def GetModuleHandle(module_name)
49
52
  GetModuleHandle.call(module_name)
50
53
  end
51
-
52
- def GetModuleHandleEx(flags, module_name, hmodule)
53
- GetModuleHandleEx.call(flags, module_name, hmodule)
54
- end
55
-
54
+
56
55
  def GetProcAddress(hmodule, proc_name)
57
56
  GetProcAddress.call(hmodule, proc_name)
58
57
  end
@@ -69,8 +68,20 @@ module Windows
69
68
  LoadModule.call(hmodule, param_block)
70
69
  end
71
70
 
72
- def SetDllDirectory(path)
73
- SetDllDirectory.call(path)
71
+ begin
72
+ def SetDllDirectory(path)
73
+ SetDllDirectory.call(path)
74
+ end
75
+
76
+ def GetModuleHandleEx(flags, module_name, hmodule)
77
+ GetModuleHandleEx.call(flags, module_name, hmodule)
78
+ end
79
+
80
+ def GetDllDirectory(length, buffer)
81
+ GetDllDirectory.call(length, buffer)
82
+ end
83
+ rescue Exception
84
+ # Windows XP or later
74
85
  end
75
86
  end
76
87
  end
@@ -0,0 +1,462 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module NetworkManagement
5
+ NERR_Success = 0
6
+ MAX_PREFERRED_LENGTH = -1
7
+
8
+ # Taken from LMServer.h
9
+ SV_TYPE_WORKSTATION = 0x00000001
10
+ SV_TYPE_SERVER = 0x00000002
11
+ SV_TYPE_SQLSERVER = 0x00000004
12
+ SV_TYPE_DOMAIN_CTRL = 0x00000008
13
+ SV_TYPE_DOMAIN_BAKCTRL = 0x00000010
14
+ SV_TYPE_TIME_SOURCE = 0x00000020
15
+ SV_TYPE_AFP = 0x00000040
16
+ SV_TYPE_NOVELL = 0x00000080
17
+ SV_TYPE_DOMAIN_MEMBER = 0x00000100
18
+ SV_TYPE_PRINTQ_SERVER = 0x00000200
19
+ SV_TYPE_DIALIN_SERVER = 0x00000400
20
+ SV_TYPE_XENIX_SERVER = 0x00000800
21
+ SV_TYPE_SERVER_UNIX = SV_TYPE_XENIX_SERVER
22
+ SV_TYPE_NT = 0x00001000
23
+ SV_TYPE_WFW = 0x00002000
24
+ SV_TYPE_SERVER_MFPN = 0x00004000
25
+ SV_TYPE_SERVER_NT = 0x00008000
26
+ SV_TYPE_POTENTIAL_BROWSER = 0x00010000
27
+ SV_TYPE_BACKUP_BROWSER = 0x00020000
28
+ SV_TYPE_MASTER_BROWSER = 0x00040000
29
+ SV_TYPE_DOMAIN_MASTER = 0x00080000
30
+ SV_TYPE_SERVER_OSF = 0x00100000
31
+ SV_TYPE_SERVER_VMS = 0x00200000
32
+ SV_TYPE_WINDOWS = 0x00400000
33
+ SV_TYPE_DFS = 0x00800000
34
+ SV_TYPE_CLUSTER_NT = 0x01000000
35
+ SV_TYPE_TERMINALSERVER = 0x02000000
36
+ SV_TYPE_CLUSTER_VS_NT = 0x04000000
37
+ SV_TYPE_DCE = 0x10000000
38
+ SV_TYPE_ALTERNATE_XPORT = 0x20000000
39
+ SV_TYPE_LOCAL_LIST_ONLY = 0x40000000
40
+ SV_TYPE_DOMAIN_ENUM = 0x80000000
41
+ SV_TYPE_ALL = 0xFFFFFFFF
42
+
43
+ NetAlertRaise = Win32API.new('netapi32', 'NetAlertRaise', 'PPL', 'L')
44
+ NetAlertRaiseEx = Win32API.new('netapi32', 'NetAlertRaiseEx', 'PPLP', 'L')
45
+ NetApiBufferAllocate = Win32API.new('netapi32', 'NetApiBufferAllocate', 'LP', 'L')
46
+ NetApiBufferFree = Win32API.new('netapi32', 'NetApiBufferFree', 'P', 'L')
47
+ NetApiBufferReallocate = Win32API.new('netapi32', 'NetApiBufferReallocate', 'PLP', 'L')
48
+ NetApiBufferSize = Win32API.new('netapi32', 'NetApiBufferSize', 'PP', 'L')
49
+ NetGetAnyDCName = Win32API.new('netapi32', 'NetGetAnyDCName', 'PPP', 'L')
50
+ NetGetDCName = Win32API.new('netapi32', 'NetGetDCName', 'PPP', 'L')
51
+
52
+ NetGetDisplayInformationIndex = Win32API.new('netapi32', 'NetGetDisplayInformationIndex', 'PLPP', 'L')
53
+ NetGetJoinableOUs = Win32API.new('netapi32', 'NetGetJoinableOUs', 'PPPPPP', 'L')
54
+ NetGetJoinInformation = Win32API.new('netapi32', 'NetGetJoinInformation', 'PPP', 'L')
55
+
56
+ NetGroupAdd = Win32API.new('netapi32', 'NetGroupAdd', 'PLPP', 'L')
57
+ NetGroupAddUser = Win32API.new('netapi32', 'NetGroupAddUser', 'PPP', 'L')
58
+ NetGroupDel = Win32API.new('netapi32', 'NetGroupDel', 'PP', 'L')
59
+ NetGroupDelUser = Win32API.new('netapi32', 'NetGroupDelUser', 'PPP', 'L')
60
+ NetGroupEnum = Win32API.new('netapi32', 'NetGroupEnum', 'PLPLPPP', 'L')
61
+ NetGroupGetInfo = Win32API.new('netapi32', 'NetGroupGetInfo', 'PPLP', 'L')
62
+ NetGroupGetUsers = Win32API.new('netapi32', 'NetGroupGetUsers', 'PPLPLPPP', 'L')
63
+ NetGroupSetInfo = Win32API.new('netapi32', 'NetGroupSetInfo', 'PPLPP', 'L')
64
+ NetGroupSetUsers = Win32API.new('netapi32', 'NetGroupSetUsers', 'PPLPL', 'L')
65
+ NetJoinDomain = Win32API.new('netapi32', 'NetJoinDomain', 'PPPPPL', 'L')
66
+
67
+ NetLocalGroupAdd = Win32API.new('netapi32', 'NetLocalGroupAdd', 'PLPP', 'L')
68
+ NetLocalGroupAddMembers = Win32API.new('netapi32', 'NetLocalGroupAddMembers', 'PPLPL', 'L')
69
+ NetLocalGroupDel = Win32API.new('netapi32', 'NetLocalGroupDel', 'PP', 'L')
70
+ NetLocalGroupDelMembers = Win32API.new('netapi32', 'NetLocalGroupDelMembers', 'PPLPL', 'L')
71
+ NetLocalGroupEnum = Win32API.new('netapi32', 'NetLocalGroupEnum', 'PLPLPPP', 'L')
72
+ NetLocalGroupGetInfo = Win32API.new('netapi32', 'NetLocalGroupGetInfo', 'PPLP', 'L')
73
+ NetLocalGroupGetMembers = Win32API.new('netapi32', 'NetLocalGroupGetMembers', 'PPLPLPPP', 'L')
74
+ NetLocalGroupSetInfo = Win32API.new('netapi32', 'NetLocalGroupSetInfo', 'PPLPP', 'L')
75
+ NetLocalGroupSetMembers = Win32API.new('netapi32', 'NetLocalGroupSetMembers', 'PPLPP', 'L')
76
+ NetMessageBufferSend = Win32API.new('netapi32', 'NetMessageBufferSend', 'PPPPL', 'L')
77
+ NetMessageNameAdd = Win32API.new('netapi32', 'NetMessageNameAdd', 'PP', 'L')
78
+ NetMessageNameDel = Win32API.new('netapi32', 'NetMessageNameDel', 'PP', 'L')
79
+ NetMessageNameEnum = Win32API.new('netapi32', 'NetMessageNameEnum', 'PLPLPPP', 'L')
80
+ NetMessageNameGetInfo = Win32API.new('netapi32', 'NetMessageNameGetInfo', 'PPLP', 'L')
81
+
82
+ NetQueryDisplayInformation = Win32API.new('netapi32', 'NetQueryDisplayInformation', 'PLLLLPP', 'L')
83
+ NetRemoteComputerSupports = Win32API.new('netapi32', 'NetRemoteComputerSupports', 'PLP', 'L')
84
+ NetRemoteTOD = Win32API.new('netapi32', 'NetRemoteTOD', 'PP', 'L')
85
+ NetRenameMachineInDomain = Win32API.new('netapi32', 'NetRenameMachineInDomain', 'PPPPL', 'L')
86
+ NetScheduleJobAdd = Win32API.new('netapi32', 'NetScheduleJobAdd', 'PPP', 'L')
87
+ NetScheduleJobDel = Win32API.new('netapi32', 'NetScheduleJobDel', 'PLL', 'L')
88
+ NetScheduleJobEnum = Win32API.new('netapi32', 'NetScheduleJobEnum', 'PPLPPP', 'L')
89
+ NetScheduleJobGetInfo = Win32API.new('netapi32', 'NetScheduleJobGetInfo', 'PLP', 'L')
90
+
91
+ NetServerComputerNameAdd = Win32API.new('netapi32', 'NetServerComputerNameAdd', 'PPP', 'L')
92
+ NetServerComputerNameDel = Win32API.new('netapi32', 'NetServerComputerNameDel', 'PP', 'L')
93
+ NetServerDiskEnum = Win32API.new('netapi32', 'NetServerDiskEnum', 'PLPLPPP', 'L')
94
+ NetServerEnum = Win32API.new('netapi32', 'NetServerEnum', 'PLPLPPLPP', 'L')
95
+ NetServerGetInfo = Win32API.new('netapi32', 'NetServerGetInfo', 'PLP', 'L')
96
+ NetServerSetInfo = Win32API.new('netapi32', 'NetServerSetInfo', 'PLPP', 'L')
97
+ NetServerTransportAdd = Win32API.new('netapi32', 'NetServerTransportAdd', 'PLP', 'L')
98
+ NetServerTransportAddEx = Win32API.new('netapi32', 'NetServerTransportAddEx', 'PLP', 'L')
99
+ NetServerTransportDel = Win32API.new('netapi32', 'NetServerTransportDel', 'PLP', 'L')
100
+ NetServerTransportEnum = Win32API.new('netapi32', 'NetServerTransportEnum', 'PLPLPPP', 'L')
101
+ NetUnjoinDomain = Win32API.new('netapi32', 'NetUnjoinDomain', 'PPPL', 'L')
102
+
103
+ NetUseAdd = Win32API.new('netapi32', 'NetUseAdd', 'PLPP', 'L')
104
+ NetUseDel = Win32API.new('netapi32', 'NetUseDel', 'PPL', 'L')
105
+ NetUseEnum = Win32API.new('netapi32', 'NetUseEnum', 'PLPLPPP', 'L')
106
+ NetUseGetInfo = Win32API.new('netapi32', 'NetUseGetInfo', 'PPLP', 'L')
107
+
108
+ NetUserAdd = Win32API.new('netapi32', 'NetUserAdd', 'PLPP', 'L')
109
+ NetUserChangePassword = Win32API.new('netapi32', 'NetUserChangePassword', 'PPPP', 'L')
110
+ NetUserDel = Win32API.new('netapi32', 'NetUserDel', 'PP', 'L')
111
+ NetUserEnum = Win32API.new('netapi32', 'NetUserEnum', 'PLLPLPPP', 'L')
112
+ NetUserGetGroups = Win32API.new('netapi32', 'NetUserGetGroups', 'PPLPLPP', 'L')
113
+ NetUserGetInfo = Win32API.new('netapi32', 'NetUserGetInfo', 'PPLP', 'L')
114
+ NetUserGetLocalGroups = Win32API.new('netapi32', 'NetUserGetLocalGroups', 'PPLLPLPP', 'L')
115
+
116
+ NetUserModalsGet = Win32API.new('netapi32', 'NetUserModalsGet', 'PLP', 'L')
117
+ NetUserModalsSet = Win32API.new('netapi32', 'NetUserModalsSet', 'PLPP', 'L')
118
+ NetUserSetGroups = Win32API.new('netapi32', 'NetUserSetGroups', 'PPLPL', 'L')
119
+ NetUserSetInfo = Win32API.new('netapi32', 'NetUserSetInfo', 'PPLPP', 'L')
120
+ NetValidateName = Win32API.new('netapi32', 'NetValidateName', 'PPPPP', 'L')
121
+
122
+ NetWkstaGetInfo = Win32API.new('netapi32', 'NetWkstaGetInfo', 'PLP', 'L')
123
+ NetWkstaSetInfo = Win32API.new('netapi32', 'NetWkstaSetInfo', 'PLPP', 'L')
124
+ NetWkstaTransportAdd = Win32API.new('netapi32', 'NetWkstaTransportAdd', 'PLPP', 'L')
125
+ NetWkstaTransportDel = Win32API.new('netapi32', 'NetWkstaTransportDel', 'PPL', 'L')
126
+ NetWkstaTransportEnum = Win32API.new('netapi32', 'NetWkstaTransportEnum', 'PLPLPPP', 'L')
127
+ NetWkstaUserEnum = Win32API.new('netapi32', 'NetWkstaUserEnum', 'PLPLPPP', 'L')
128
+ NetWkstaUserGetInfo = Win32API.new('netapi32', 'NetWkstaUserGetInfo', 'PLP', 'L')
129
+ NetWkstaUserSetInfo = Win32API.new('netapi32', 'NetWkstaUserSetInfo', 'PPLP', 'L')
130
+
131
+ begin
132
+ GetNetScheduleAccountInformation = Win32API.new('mstask', 'GetNetScheduleAccountInformation', 'PLP', 'L')
133
+ SetNetScheduleAccountInformation = Win32API.new('netapi32', 'SetNetScheduleAccountInformation', 'PPP', 'L')
134
+ rescue Exception
135
+ # Do nothing. Not supported on current platform
136
+ end
137
+
138
+ def NetAlertRaise(name, buf, bufsize)
139
+ NetAlertRaise.call(name, buf, bufsize) == NERR_Success
140
+ end
141
+
142
+ def NetAlertRaiseEx(name, data, size, service)
143
+ NetAlertRaiseEx.call(name, data, size, service) == NERR_Success
144
+ end
145
+
146
+ def NetApiBufferAllocate(num_bytes, buf)
147
+ NetApiBufferAllocate.call(num_bytes, buf) == NERR_Success
148
+ end
149
+
150
+ def NetApiBufferFree(buf)
151
+ NetApiBufferFree.call(buf) == NERR_Success
152
+ end
153
+
154
+ def NetApiBufferReallocate(old_buf, count, new_buf)
155
+ NetApiBufferReallocate.call(old_buf, count, new_buf) == NERR_Success
156
+ end
157
+
158
+ def NetApiBufferSize(buf, count)
159
+ NetApiBufferSize.call(buf, count) == NERR_Success
160
+ end
161
+
162
+ def NetGetAnyDCName(server, domain, buf)
163
+ NetGetAnyDCName.call(server, domain, buf) == NERR_Success
164
+ end
165
+
166
+ def NetGetDCName(server, domain, buf)
167
+ NetGetDCName.call(server, domain, buf) == NERR_Success
168
+ end
169
+
170
+ def NetGetDisplayInformationIndex(server, level, prefix, index)
171
+ NetGetDisplayInformationIndex.call(server, level, prefix, index) == NERR_Success
172
+ end
173
+
174
+ def NetGetJoinableOUs(server, domain, account, password, count, ous)
175
+ NetGetJoinableOUs.call(server, domain, account, password, count, ous) == NERR_Success
176
+ end
177
+
178
+ def NetGetJoinInformation(server, buf, buf_type)
179
+ NetGetJoinInformation.call(server, buf, buf_type) == NERR_Success
180
+ end
181
+
182
+ def NetGroupAdd(server, level, buf, err)
183
+ NetGroupAdd.call(server, level, buf, err).call == NERR_Success
184
+ end
185
+
186
+ def NetGroupAddUser(server, group, user)
187
+ NetGroupAddUser.call(server, group, user) == NERR_Success
188
+ end
189
+
190
+ def NetGroupDel(server, group)
191
+ NetGroupDel.call(server, group) == NERR_Success
192
+ end
193
+
194
+ def NetGroupDelUser(server, group, user)
195
+ NetGroupDelUser.call(server, group, user) == NERR_Success
196
+ end
197
+
198
+ def NetGroupEnum(server, level, buf, max, entries, total_entries, resume)
199
+ NetGroupEnum.call(server, level, buf, max, entries, total_entries, resume) == NERR_Success
200
+ end
201
+
202
+ def NetGroupGetInfo(server, group, level, buf)
203
+ NetGroupGetInfo.call(server, group, level, buf) == NERR_Success
204
+ end
205
+
206
+ def NetGroupGetUsers(server, group, level, buf, max, entries, total_entries, resume)
207
+ NetGroupGetUsers.call(server, group, level, buf, max, entries, total_entries, resume) == NERR_Success
208
+ end
209
+
210
+ def NetGroupSetInfo(server, group, level, buf, err)
211
+ NetGroupSetInfo.call(server, group, level, buf, err) == NERR_Success
212
+ end
213
+
214
+ def NetGroupSetUsers(server, group, level, buf, total)
215
+ NetGroupSetUsers.call(server, group, level, buf, total) == NERR_Success
216
+ end
217
+
218
+ def NetJoinDomain(server, domain, account_ou, account, password, opts)
219
+ NetJoinDomain.call(server, domain, account_ou, account, password, opts) == NERR_Success
220
+ end
221
+
222
+ def NetLocalGroupAdd(server, level, buf, err)
223
+ NetLocalGroupAdd.call(server, level, buf, err) == NERR_Success
224
+ end
225
+
226
+ def NetLocalGroupAddMembers(server, group, level, buf, total)
227
+ NetLocalGroupAddMembers.call(server, group, level, buf, total) == NERR_Success
228
+ end
229
+
230
+ def NetLocalGroupDel(server, group)
231
+ NetLocalGroupDel.call(server, group) == NERR_Success
232
+ end
233
+
234
+ def NetLocalGroupDelMembers(server, group, level, buf, total)
235
+ NetLocalGroupDelMembers.call(server, group, level, buf, total) == NERR_Success
236
+ end
237
+
238
+ def NetLocalGroupEnum(server, level, buf, max, entries, total_entries, resume)
239
+ NetLocalGroupEnum.call(server, level, buf, max, entries, total_entries, resume) == NERR_Success
240
+ end
241
+
242
+ def NetLocalGroupGetInfo(server, group, level, buf)
243
+ NetLocalGroupGetInfo.call(server, group, level, buf) == NERR_Success
244
+ end
245
+
246
+ def NetLocalGroupGetMembers(server, group, level, buf, max, entries, total_entries, resume)
247
+ NetLocalGroupGetMembers.call(server, group, level, buf, max, entries, total_entries, resume) == NERR_Success
248
+ end
249
+
250
+ def NetLocalGroupSetInfo(server, group, level, buf, err)
251
+ NetLocalGroupSetInfo.call(server, group, level, buf, err) == NERR_Success
252
+ end
253
+
254
+ def NetLocalGroupSetMembers(server, group, level, buf, total)
255
+ NetLocalGroupSetMembers.call(server, group, level, buf, total) == NERR_Success
256
+ end
257
+
258
+ def NetMessageBufferSend(server, msg, from, buf, bufsize)
259
+ NetMessageBufferSend.call(server, msg, from, buf, bufsize) == NERR_Success
260
+ end
261
+
262
+ def NetMessageNameAdd(server, msg)
263
+ NetMessageNameAdd.call(server, msg) == NERR_Success
264
+ end
265
+
266
+ def NetMessageNameDel(server, msg)
267
+ NetMessageNameDel.call(server, msg) == NERR_Success
268
+ end
269
+
270
+ def NetMessageNameEnum(server, level, buf, max, entries, total_entries, resume)
271
+ NetMessageNameEnum.call(server, level, buf, max, entries, total_entries, resume) == NERR_Success
272
+ end
273
+
274
+ def NetMessageNameGetInfo(server, msg, level, buf)
275
+ NetMessageNameGetInfo.call(server, msg, level, buf) == NERR_Success
276
+ end
277
+
278
+ def NetQueryDisplayInformation(server, level, index, entries, max, count, buf)
279
+ NetQueryDisplayInformation.call(server, level, index, entries, max, count, buf) == NERR_Success
280
+ end
281
+
282
+ def NetRemoteComputerSupports(server, level, index, entries, max, count, buf)
283
+ NetRemoteComputerSupports.call(server, level, index, entries, max, count, buf) == NERR_Success
284
+ end
285
+
286
+ def NetRemoteTOD(server, buf)
287
+ NetRemoteTOD.call(server, buf) == NERR_Success
288
+ end
289
+
290
+ def NetRenameMachineInDomain(server, machine, account, password, options)
291
+ NetRenameMachineInDomain.call(server, machine, account, password, options) == NERR_Success
292
+ end
293
+
294
+ def NetScheduleJobAdd(server, buf, job)
295
+ NetScheduleJobAdd.call(server, buf, job) == NERR_Success
296
+ end
297
+
298
+ def NetScheduleJobDel(server, min, max)
299
+ NetScheduleJobDel.call(server, min, max) == NERR_Success
300
+ end
301
+
302
+ def NetScheduleJobEnum(server, buf, max, entries, total_entries, resume)
303
+ NetScheduleJobEnum.call(server, buf, max, entries, total_entries, resume) == NERR_Success
304
+ end
305
+
306
+ def NetScheduleJobGetInfo(server, job, buf)
307
+ NetScheduleJobGetInfo.call(server, job, buf) == NERR_Success
308
+ end
309
+
310
+ def NetServerComputerNameAdd(server, em_domain, em_server)
311
+ NetServerComputerNameAdd.call(server, em_domain, em_server) == NERR_Success
312
+ end
313
+
314
+ def NetServerComputerNameDel(server, em_server)
315
+ NetServerComputerNameDel.call(server, em_server) == NERR_Success
316
+ end
317
+
318
+ def NetServerDiskEnum(server, level, buf, maxlen, entries, total_entries, resume)
319
+ NetServerDiskEnum.call(server, level, buf, maxlen, entries, total_entries, resume) == NERR_Success
320
+ end
321
+
322
+ def NetServerEnum(server, level, ptr, maxlen, num, total, stype, domain, handle)
323
+ NetServerEnum.call(server, level, ptr, maxlen, num, total, stype, domain, handle) == NERR_Success
324
+ end
325
+
326
+ def NetServerGetInfo(server, level, buf)
327
+ NetServerGetInfo.call(server, level, buf) == NERR_Success
328
+ end
329
+
330
+ def NetServerSetInfo(server, level, buf, error)
331
+ NetServerSetInfo.call(server, level, buf, error) == NERR_Success
332
+ end
333
+
334
+ def NetServerTransportAdd(server, level, buf)
335
+ NetServerTransportAdd.call(server, level, buf) == NERR_Success
336
+ end
337
+
338
+ def NetServerTransportAddEx(server, level, buf)
339
+ NetServerTransportAddEx.call(server, level, buf) == NERR_Success
340
+ end
341
+
342
+ def NetServerTransportDel(server, level, buf)
343
+ NetServerTransportDel.call(server, level, buf) == NERR_Success
344
+ end
345
+
346
+ def NetServerTransportEnum(server, level, buf, maxlen, entries, total_entries, resume)
347
+ NetServerTransportEnum.call(server, level, buf, maxlen, entries, total_entries, resume) == NERR_Success
348
+ end
349
+
350
+ def NetUnjoinDomain(server, account, password, options)
351
+ NetUnjoinDomain.call(server, account, password, options) == NERR_Success
352
+ end
353
+
354
+ def NetUseAdd(server, level, buf, error)
355
+ NetUseAdd.call(server, level, buf, error) == NERR_Success
356
+ end
357
+
358
+ def NetUseDel(server, name, conn)
359
+ NetUseDel.call(server, name, conn) == NERR_Success
360
+ end
361
+
362
+ def NetUseEnum(server, level, buf, max, entries, total_entries, resume)
363
+ NetUseEnum.call(server, level, buf, max, entries, total_entries, resume) == NERR_Success
364
+ end
365
+
366
+ def NetUseGetInfo(server, name, level, buf)
367
+ NetUseGetInfo.call(server, name, level, buf) == NERR_Success
368
+ end
369
+
370
+ def NetUserAdd(server, level, buf, error)
371
+ NetUserAdd.call(server, level, buf, error) == NERR_Success
372
+ end
373
+
374
+ def NetUserChangePassword(domain, user, old, new)
375
+ NetUserChangePassword.call(domain, user, old, new) == NERR_Success
376
+ end
377
+
378
+ def NetUserDel(server, user)
379
+ NetUserDel.call(server, user) == NERR_Success
380
+ end
381
+
382
+ def NetUserEnum(server, level, filter, buf, max, entries, total_entries, resume)
383
+ NetUserEnum.call(server, level, filter, buf, max, entries, total_entries, resume) == NERR_Success
384
+ end
385
+
386
+ def NetUserGetGroups(server, user, level, buf, max, entries, total_entries)
387
+ NetUserGetGroups.call(server, user, level, buf, max, entries, total_entries) == NERR_Success
388
+ end
389
+
390
+ def NetUserGetInfo(server, user, level, buf)
391
+ NetUserGetInfo.call(server, user, level, buf) == NERR_Success
392
+ end
393
+
394
+ def NetUserGetLocalGroups(server, user, level, flags, buf, max, entries, total_entries)
395
+ NetUserGetLocalGroups.call(server, user, level, flags, buf, max, entries, total_entries) == NERR_Success
396
+ end
397
+
398
+ def NetUserModalsGet(server, level, buf)
399
+ NetUserModalsGet.call(server, level, buf) == NERR_Success
400
+ end
401
+
402
+ def NetUserModalsSet(server, level, buf, error)
403
+ NetUserModalsSet.call(server, level, buf, error) == NERR_Success
404
+ end
405
+
406
+ def NetUserSetGroups(server, user, level, buf, num)
407
+ NetUserSetGroups.call(server, user, level, buf, num) == NERR_Success
408
+ end
409
+
410
+ def NetUserSetInfo(server, user, level, buf, error)
411
+ NetUserSetInfo.call(server, user, level, buf, error) == NERR_Success
412
+ end
413
+
414
+ def NetValidateName(server, name, account, password, name_type)
415
+ NetValidateName.call(server, name, account, password, name_type) == NERR_Success
416
+ end
417
+
418
+ def NetWkstaGetInfo(server, level, buf)
419
+ NetWkstaGetInfo.call(server, level, buf) == NERR_Success
420
+ end
421
+
422
+ def NetWkstaSetInfo.call(server, level, buf, error)
423
+ NetWkstaSetInfo.call(server, level, buf, error) == NERR_Success
424
+ end
425
+
426
+ def NetWkstaTransportAdd(server, level, buf, error)
427
+ NetWkstaTransportAdd.call(server, level, buf, error) == NERR_Success
428
+ end
429
+
430
+ def NetWkstaTransportDel(server, name, cond)
431
+ NetWkstaTransportDel.call(server, name, cond) == NERR_Success
432
+ end
433
+
434
+ def NetWkstaTransportEnum(server, level, buf, maxlen, entries, total_entries, resume)
435
+ NetWkstaTransportEnum.call(server, level, buf, maxlen, entries, total_entries, resume) == NERR_Success
436
+ end
437
+
438
+ def NetWkstaUserEnum(server, level, buf, maxlen, entries, total_entries, resume)
439
+ NetWkstaUserEnum.call(server, level, buf, maxlen, entries, total_entries, resume) == NERR_Success
440
+ end
441
+
442
+ def NetWkstaUserGetInfo(res, level, buf)
443
+ NetWkstaUserGetInfo.call(res, level, buf) == NERR_Success
444
+ end
445
+
446
+ def NetWkstaUserSetInfo(res, level, buf, error)
447
+ NetWkstaUserSetInfo.call(res, level, buf, error) == NERR_Success
448
+ end
449
+
450
+ # Windows XP or later
451
+ begin
452
+ def GetNetScheduleAccountInformation(server, num_chars, chars)
453
+ GetNetScheduleAccountInformation.call(server, num_chars, chars) == NERR_Success
454
+ end
455
+
456
+ def SetNetScheduleAccountInformation(server, account, password)
457
+ SetNetScheduleAccountInformation.call(server, account, password) == NERR_Success
458
+ end
459
+ rescue Exception
460
+ end
461
+ end
462
+ end
@@ -1,34 +1,3 @@
1
- #######################################################################
2
- # synchronize.rb
3
- #
4
- # Defines the following functions:
5
- #
6
- # CreateEvent()
7
- # CreateMutex()
8
- # CreateSemaphore()
9
- # MsgWaitForMultipleObjects()
10
- # MsgWaitForMultipleObjectsEx()
11
- # OpenEvent()
12
- # OpenMutex()
13
- # OpenSemaphore()
14
- # WaitForDebugEvent()
15
- # WaitForSingleObject()
16
- # WaitForSingleObjectEx()
17
- # WaitForMultipleObjects()
18
- # WaitForMultipleObjectsEx()
19
- #
20
- # Defines the the following constants:
21
- #
22
- # WAIT_ABANDONED
23
- # WAIT_OBJECT_0
24
- # WAIT_TIMEOUT
25
- # WAIT_FAILED
26
- # INFINITE
27
- #
28
- # TODO:
29
- #
30
- # Add the rest of the synchronization functions.
31
- #######################################################################
32
1
  require 'Win32API'
33
2
 
34
3
  module Windows
data/test/tc_error.rb CHANGED
@@ -40,7 +40,7 @@ class TC_Windows_Error < Test::Unit::TestCase
40
40
  def test_method_constants
41
41
  assert_not_nil(Foo::GetLastError)
42
42
  assert_not_nil(Foo::SetLastError)
43
- assert_not_nil(Foo::SetLastErrorEx)
43
+ assert_not_nil(Foo::SetLastErrorEx) # Ignore for VC++ 6 or earlier.
44
44
  assert_not_nil(Foo::SetErrorMode)
45
45
  assert_not_nil(Foo::FormatMessage)
46
46
  end
@@ -0,0 +1,44 @@
1
+ #####################################################################
2
+ # tc_library.rb
3
+ #
4
+ # Test case for the Windows::Library module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require 'windows/library'
14
+ require 'test/unit'
15
+
16
+ class Foo
17
+ include Windows::Library
18
+ end
19
+
20
+ class TC_Windows_Library < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_numeric_constants
26
+ assert_equal(0, Foo::DLL_PROCESS_DETACH)
27
+ assert_equal(1, Foo::DLL_PROCESS_ATTACH)
28
+ assert_equal(2, Foo::DLL_THREAD_ATTACH)
29
+ assert_equal(3, Foo::DLL_THREAD_DETACH)
30
+ end
31
+
32
+ def test_method_constants
33
+ assert_not_nil(Foo::FreeLibrary)
34
+ assert_not_nil(Foo::GetModuleFileName)
35
+ assert_not_nil(Foo::GetModuleHandle)
36
+ assert_not_nil(Foo::LoadLibrary)
37
+ assert_not_nil(Foo::LoadLibraryEx)
38
+ assert_not_nil(Foo::LoadModule)
39
+ end
40
+
41
+ def teardown
42
+ @foo = nil
43
+ end
44
+ end
@@ -0,0 +1,25 @@
1
+ require "rubygems"
2
+
3
+ spec = Gem::Specification.new do |gem|
4
+ gem.name = "windows-pr"
5
+ gem.version = "0.5.4"
6
+ gem.author = "Daniel J. Berger"
7
+ gem.email = "djberg96@gmail.com"
8
+ gem.homepage = "http://www.rubyforge.org/projects/win32utils"
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.summary = "Windows functions and constants predefined via Win32API"
11
+ gem.description = "Windows functions and constants predefined via Win32API"
12
+ gem.test_file = "test/ts_all.rb"
13
+ gem.has_rdoc = true
14
+ gem.files = Dir["doc/*.txt"] + Dir["lib/windows/*.rb"]
15
+ gem.files += Dir["lib/windows/msvcrt/*.rb"]
16
+ gem.files += Dir["test/*"] + Dir["[A-Z]*"]
17
+ gem.files.reject! { |fn| fn.include? "CVS" }
18
+ gem.require_path = "lib"
19
+ gem.extra_rdoc_files = ["README", "CHANGES"]
20
+ end
21
+
22
+ if $0 == __FILE__
23
+ Gem.manage_gems
24
+ Gem::Builder.new(spec).build
25
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: windows-pr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.3
7
- date: 2006-08-10 00:00:00 -06:00
6
+ version: 0.5.4
7
+ date: 2006-09-08 00:00:00 -06:00
8
8
  summary: Windows functions and constants predefined via Win32API
9
9
  require_paths:
10
10
  - lib
@@ -38,11 +38,13 @@ files:
38
38
  - lib/windows/eventlog.rb
39
39
  - lib/windows/file.rb
40
40
  - lib/windows/filesystem.rb
41
+ - lib/windows/file_mapping.rb
41
42
  - lib/windows/handle.rb
42
43
  - lib/windows/library.rb
43
44
  - lib/windows/limits.rb
44
45
  - lib/windows/memory.rb
45
46
  - lib/windows/national.rb
47
+ - lib/windows/network_management.rb
46
48
  - lib/windows/path.rb
47
49
  - lib/windows/pipe.rb
48
50
  - lib/windows/process.rb
@@ -65,6 +67,7 @@ files:
65
67
  - test/tc_error.rb
66
68
  - test/tc_eventlog.rb
67
69
  - test/tc_file.rb
70
+ - test/tc_library.rb
68
71
  - test/tc_memory.rb
69
72
  - test/tc_msvcrt_buffer.rb
70
73
  - test/tc_path.rb
@@ -76,8 +79,13 @@ files:
76
79
  - test/tc_unicode.rb
77
80
  - CHANGES
78
81
  - CVS
82
+ - doc
83
+ - install.rb
84
+ - lib
79
85
  - MANIFEST
80
86
  - README
87
+ - test
88
+ - windows-pr.gemspec
81
89
  test_files:
82
90
  - test/ts_all.rb
83
91
  rdoc_options: []