windows-pr 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/CHANGES +408 -404
  2. data/MANIFEST +65 -65
  3. data/README +149 -149
  4. data/Rakefile +52 -52
  5. data/doc/conversion_guide.txt +37 -37
  6. data/lib/windows/clipboard.rb +59 -59
  7. data/lib/windows/com.rb +190 -189
  8. data/lib/windows/com/automation.rb +147 -147
  9. data/lib/windows/com/variant.rb +22 -22
  10. data/lib/windows/console.rb +112 -112
  11. data/lib/windows/debug.rb +33 -33
  12. data/lib/windows/device_io.rb +246 -246
  13. data/lib/windows/directory.rb +25 -25
  14. data/lib/windows/error.rb +482 -482
  15. data/lib/windows/eventlog.rb +78 -78
  16. data/lib/windows/file.rb +262 -262
  17. data/lib/windows/file_mapping.rb +23 -23
  18. data/lib/windows/filesystem.rb +13 -13
  19. data/lib/windows/gdi/bitmap.rb +63 -63
  20. data/lib/windows/gdi/device_context.rb +44 -44
  21. data/lib/windows/gdi/metafile.rb +38 -38
  22. data/lib/windows/gdi/painting_drawing.rb +113 -113
  23. data/lib/windows/handle.rb +21 -21
  24. data/lib/windows/library.rb +42 -42
  25. data/lib/windows/limits.rb +31 -31
  26. data/lib/windows/mailslot.rb +22 -22
  27. data/lib/windows/memory.rb +126 -126
  28. data/lib/windows/msvcrt/buffer.rb +73 -73
  29. data/lib/windows/msvcrt/directory.rb +29 -29
  30. data/lib/windows/msvcrt/file.rb +45 -45
  31. data/lib/windows/msvcrt/io.rb +71 -71
  32. data/lib/windows/msvcrt/time.rb +167 -167
  33. data/lib/windows/national.rb +578 -578
  34. data/lib/windows/network/management.rb +523 -523
  35. data/lib/windows/network/snmp.rb +90 -90
  36. data/lib/windows/network/winsock.rb +126 -126
  37. data/lib/windows/nio.rb +48 -47
  38. data/lib/windows/ntfs/winternl.rb +96 -96
  39. data/lib/windows/path.rb +141 -141
  40. data/lib/windows/pipe.rb +40 -40
  41. data/lib/windows/process.rb +174 -174
  42. data/lib/windows/registry.rb +126 -126
  43. data/lib/windows/security.rb +477 -477
  44. data/lib/windows/security/authentication.rb +30 -30
  45. data/lib/windows/service.rb +140 -140
  46. data/lib/windows/shell.rb +169 -169
  47. data/lib/windows/sound.rb +37 -37
  48. data/lib/windows/synchronize.rb +131 -131
  49. data/lib/windows/system_info.rb +227 -222
  50. data/lib/windows/thread.rb +62 -62
  51. data/lib/windows/time.rb +46 -46
  52. data/lib/windows/tool_helper.rb +34 -34
  53. data/lib/windows/volume.rb +59 -59
  54. data/lib/windows/window.rb +79 -79
  55. data/lib/windows/window/classes.rb +57 -57
  56. data/lib/windows/window/dialog.rb +89 -89
  57. data/lib/windows/window/menu.rb +100 -100
  58. data/lib/windows/window/message.rb +295 -295
  59. data/lib/windows/window/properties.rb +18 -18
  60. data/lib/windows/window/timer.rb +17 -17
  61. data/test/tc_clipboard.rb +41 -41
  62. data/test/tc_com.rb +32 -32
  63. data/test/tc_com_automation.rb +15 -15
  64. data/test/tc_console.rb +108 -108
  65. data/test/tc_debug.rb +48 -48
  66. data/test/tc_device_io.rb +29 -29
  67. data/test/tc_directory.rb +25 -25
  68. data/test/tc_error.rb +49 -49
  69. data/test/tc_eventlog.rb +58 -58
  70. data/test/tc_file.rb +67 -67
  71. data/test/tc_file_mapping.rb +38 -38
  72. data/test/tc_filesystem.rb +27 -27
  73. data/test/tc_gdi_bitmap.rb +25 -25
  74. data/test/tc_gdi_metafile.rb +23 -23
  75. data/test/tc_handle.rb +36 -36
  76. data/test/tc_library.rb +37 -37
  77. data/test/tc_limits.rb +34 -34
  78. data/test/tc_mailslot.rb +22 -22
  79. data/test/tc_memory.rb +44 -44
  80. data/test/tc_msvcrt_buffer.rb +68 -68
  81. data/test/tc_msvcrt_directory.rb +98 -98
  82. data/test/tc_msvcrt_file.rb +80 -80
  83. data/test/tc_msvcrt_io.rb +48 -48
  84. data/test/tc_msvcrt_string.rb +93 -93
  85. data/test/tc_msvcrt_time.rb +29 -29
  86. data/test/tc_national.rb +38 -38
  87. data/test/tc_network_management.rb +32 -32
  88. data/test/tc_network_snmp.rb +31 -31
  89. data/test/tc_network_winsock.rb +34 -34
  90. data/test/tc_nio.rb +32 -32
  91. data/test/tc_ntfs_winternl.rb +29 -29
  92. data/test/tc_path.rb +90 -90
  93. data/test/tc_pipe.rb +53 -53
  94. data/test/tc_process.rb +24 -24
  95. data/test/tc_registry.rb +29 -29
  96. data/test/tc_security.rb +104 -104
  97. data/test/tc_security_authentication.rb +34 -34
  98. data/test/tc_service.rb +57 -57
  99. data/test/tc_shell.rb +34 -34
  100. data/test/tc_sound.rb +37 -37
  101. data/test/tc_synchronize.rb +75 -75
  102. data/test/tc_system_info.rb +43 -43
  103. data/test/tc_thread.rb +29 -29
  104. data/test/tc_time.rb +32 -32
  105. data/test/tc_tool_helper.rb +29 -29
  106. data/test/tc_volume.rb +47 -47
  107. data/test/tc_window.rb +45 -45
  108. data/test/tc_window_classes.rb +33 -33
  109. data/test/tc_window_dialog.rb +33 -33
  110. data/test/tc_window_menu.rb +29 -29
  111. data/test/tc_window_message.rb +33 -33
  112. data/test/tc_window_properties.rb +29 -29
  113. data/test/tc_window_timer.rb +29 -29
  114. data/windows-pr.gemspec +34 -34
  115. metadata +4 -4
@@ -1,62 +1,62 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module Thread
5
- API.auto_namespace = 'Windows::Thread'
6
- API.auto_constant = true
7
- API.auto_method = true
8
- API.auto_unicode = true
9
-
10
- SYNCHRONIZE = 0x00100000
11
- THREAD_ALL_ACCESS = 0x1F03FF
12
- THREAD_DIRECT_IMPERSONATION = 0x0200
13
- THREAD_GET_CONTEXT = 0x0008
14
- THREAD_IMPERSONATE = 0x0100
15
- THREAD_QUERY_INFORMATION = 0x0040
16
- THREAD_SET_CONTEXT = 0x0010
17
- THREAD_SET_INFORMATION = 0x0020
18
- THREAD_SET_THREAD_TOKEN = 0x0080
19
- THREAD_SUSPEND_RESUME = 0x0002
20
- THREAD_TERMINATE = 0x0001
21
-
22
- THREAD_PRIORITY_ABOVE_NORMAL = 1
23
- THREAD_PRIORITY_BELOW_NORMAL = -1
24
- THREAD_PRIORITY_HIGHEST = 2
25
- THREAD_PRIORITY_IDLE = -15
26
- THREAD_PRIORITY_LOWEST = -2
27
- THREAD_PRIORITY_NORMAL = 0
28
- THREAD_PRIORITY_TIME_CRITICAL = 15
29
-
30
- API.new('CreateRemoteThread', 'LPLLPLP', 'L')
31
- API.new('CreateThread', 'PLKPLP', 'L')
32
- API.new('ExitThread', 'L', 'V')
33
- API.new('GetCurrentThread', 'V', 'L')
34
- API.new('GetCurrentThreadId', 'V', 'L')
35
- API.new('GetExitCodeThread', 'LP', 'B')
36
- API.new('GetThreadPriority', 'L', 'I')
37
- API.new('GetThreadPriorityBoost', 'LP', 'B')
38
- API.new('GetThreadTimes', 'LPPPP', 'B')
39
- API.new('OpenThread', 'LIL', 'L')
40
- API.new('ResumeThread', 'L', 'L')
41
- API.new('SetThreadAffinityMask', 'LP', 'P')
42
- API.new('SetThreadIdealProcessor', 'LL', 'L')
43
- API.new('SetThreadPriority', 'LI', 'B')
44
- API.new('SetThreadPriorityBoost', 'LI', 'B')
45
- API.new('Sleep', 'L', 'V')
46
- API.new('SleepEx', 'LI', 'L')
47
- API.new('SuspendThread', 'L', 'L')
48
- API.new('SwitchToThread', 'V', 'B')
49
- API.new('TerminateThread', 'LL', 'B')
50
- API.new('TlsAlloc', 'V', 'L')
51
- API.new('TlsFree', 'L', 'B')
52
- API.new('TlsGetValue', 'L', 'L')
53
- API.new('TlsSetValue', 'LL', 'B')
54
-
55
- begin
56
- API.new('AttachThreadInput', 'LLI', 'B', 'user32')
57
- API.new('GetThreadIOPendingFlag', 'LP', 'B')
58
- rescue Win32::API::LoadLibraryError
59
- # Windows XP or later
60
- end
61
- end
62
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Thread
5
+ API.auto_namespace = 'Windows::Thread'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
10
+ SYNCHRONIZE = 0x00100000
11
+ THREAD_ALL_ACCESS = 0x1F03FF
12
+ THREAD_DIRECT_IMPERSONATION = 0x0200
13
+ THREAD_GET_CONTEXT = 0x0008
14
+ THREAD_IMPERSONATE = 0x0100
15
+ THREAD_QUERY_INFORMATION = 0x0040
16
+ THREAD_SET_CONTEXT = 0x0010
17
+ THREAD_SET_INFORMATION = 0x0020
18
+ THREAD_SET_THREAD_TOKEN = 0x0080
19
+ THREAD_SUSPEND_RESUME = 0x0002
20
+ THREAD_TERMINATE = 0x0001
21
+
22
+ THREAD_PRIORITY_ABOVE_NORMAL = 1
23
+ THREAD_PRIORITY_BELOW_NORMAL = -1
24
+ THREAD_PRIORITY_HIGHEST = 2
25
+ THREAD_PRIORITY_IDLE = -15
26
+ THREAD_PRIORITY_LOWEST = -2
27
+ THREAD_PRIORITY_NORMAL = 0
28
+ THREAD_PRIORITY_TIME_CRITICAL = 15
29
+
30
+ API.new('CreateRemoteThread', 'LPLLPLP', 'L')
31
+ API.new('CreateThread', 'PLKPLP', 'L')
32
+ API.new('ExitThread', 'L', 'V')
33
+ API.new('GetCurrentThread', 'V', 'L')
34
+ API.new('GetCurrentThreadId', 'V', 'L')
35
+ API.new('GetExitCodeThread', 'LP', 'B')
36
+ API.new('GetThreadPriority', 'L', 'I')
37
+ API.new('GetThreadPriorityBoost', 'LP', 'B')
38
+ API.new('GetThreadTimes', 'LPPPP', 'B')
39
+ API.new('OpenThread', 'LIL', 'L')
40
+ API.new('ResumeThread', 'L', 'L')
41
+ API.new('SetThreadAffinityMask', 'LP', 'P')
42
+ API.new('SetThreadIdealProcessor', 'LL', 'L')
43
+ API.new('SetThreadPriority', 'LI', 'B')
44
+ API.new('SetThreadPriorityBoost', 'LI', 'B')
45
+ API.new('Sleep', 'L', 'V')
46
+ API.new('SleepEx', 'LI', 'L')
47
+ API.new('SuspendThread', 'L', 'L')
48
+ API.new('SwitchToThread', 'V', 'B')
49
+ API.new('TerminateThread', 'LL', 'B')
50
+ API.new('TlsAlloc', 'V', 'L')
51
+ API.new('TlsFree', 'L', 'B')
52
+ API.new('TlsGetValue', 'L', 'L')
53
+ API.new('TlsSetValue', 'LL', 'B')
54
+
55
+ begin
56
+ API.new('AttachThreadInput', 'LLI', 'B', 'user32')
57
+ API.new('GetThreadIOPendingFlag', 'LP', 'B')
58
+ rescue Win32::API::LoadLibraryError
59
+ # Windows XP or later
60
+ end
61
+ end
62
+ end
data/lib/windows/time.rb CHANGED
@@ -1,46 +1,46 @@
1
- require 'windows/api'
2
-
3
- # In general you will want to use this module with Windows::National because
4
- # it contains the various LOCALE and TIME constants.
5
-
6
- module Windows
7
- module Time
8
- API.auto_namespace = 'Windows::Time'
9
- API.auto_constant = true
10
- API.auto_method = true
11
- API.auto_unicode = true
12
-
13
- TIME_ZONE_ID_UNKNOWN = 0
14
- TIME_ZONE_ID_STANDARD = 1
15
- TIME_ZONE_ID_DAYLIGHT = 2
16
-
17
- API.new('CompareFileTime', 'PP', 'L')
18
- API.new('DosDateTimeToFileTime', 'IIP', 'B')
19
- API.new('FileTimeToDosDateTime', 'PPP', 'B')
20
- API.new('FileTimeToLocalFileTime', 'PP', 'B')
21
- API.new('FileTimeToSystemTime', 'PP', 'B')
22
- API.new('GetFileTime', 'LPPP', 'B')
23
- API.new('GetLocalTime', 'P')
24
- API.new('GetSystemTime', 'P')
25
- API.new('GetSystemTimeAdjustment', 'PPP', 'B')
26
- API.new('GetSystemTimeAsFileTime', 'P')
27
- API.new('GetTickCount')
28
- API.new('GetTimeFormat', 'ILPPPI', 'I')
29
- API.new('GetTimeZoneInformation', 'P', 'L')
30
- API.new('LocalFileTimeToFileTime', 'PP', 'B')
31
- API.new('SetFileTime', 'LPPP', 'B')
32
- API.new('SetLocalTime', 'P', 'B')
33
- API.new('SetSystemTime', 'P', 'B')
34
- API.new('SetTimeZoneInformation', 'P', 'B')
35
- API.new('SetSystemTimeAdjustment', 'LI', 'B')
36
- API.new('SystemTimeToFileTime', 'PP', 'B')
37
- API.new('SystemTimeToTzSpecificLocalTime', 'PPP', 'B')
38
-
39
- begin
40
- API.new('GetSystemTimes', 'PPP', 'B')
41
- API.new('TzSpecificLocalTimeToSystemTime', 'PPP', 'B')
42
- rescue Win32::API::LoadLibraryError
43
- # Windows XP or later
44
- end
45
- end
46
- end
1
+ require 'windows/api'
2
+
3
+ # In general you will want to use this module with Windows::National because
4
+ # it contains the various LOCALE and TIME constants.
5
+
6
+ module Windows
7
+ module Time
8
+ API.auto_namespace = 'Windows::Time'
9
+ API.auto_constant = true
10
+ API.auto_method = true
11
+ API.auto_unicode = true
12
+
13
+ TIME_ZONE_ID_UNKNOWN = 0
14
+ TIME_ZONE_ID_STANDARD = 1
15
+ TIME_ZONE_ID_DAYLIGHT = 2
16
+
17
+ API.new('CompareFileTime', 'PP', 'L')
18
+ API.new('DosDateTimeToFileTime', 'IIP', 'B')
19
+ API.new('FileTimeToDosDateTime', 'PPP', 'B')
20
+ API.new('FileTimeToLocalFileTime', 'PP', 'B')
21
+ API.new('FileTimeToSystemTime', 'PP', 'B')
22
+ API.new('GetFileTime', 'LPPP', 'B')
23
+ API.new('GetLocalTime', 'P')
24
+ API.new('GetSystemTime', 'P')
25
+ API.new('GetSystemTimeAdjustment', 'PPP', 'B')
26
+ API.new('GetSystemTimeAsFileTime', 'P')
27
+ API.new('GetTickCount')
28
+ API.new('GetTimeFormat', 'ILPPPI', 'I')
29
+ API.new('GetTimeZoneInformation', 'P', 'L')
30
+ API.new('LocalFileTimeToFileTime', 'PP', 'B')
31
+ API.new('SetFileTime', 'LPPP', 'B')
32
+ API.new('SetLocalTime', 'P', 'B')
33
+ API.new('SetSystemTime', 'P', 'B')
34
+ API.new('SetTimeZoneInformation', 'P', 'B')
35
+ API.new('SetSystemTimeAdjustment', 'LI', 'B')
36
+ API.new('SystemTimeToFileTime', 'PP', 'B')
37
+ API.new('SystemTimeToTzSpecificLocalTime', 'PPP', 'B')
38
+
39
+ begin
40
+ API.new('GetSystemTimes', 'PPP', 'B')
41
+ API.new('TzSpecificLocalTimeToSystemTime', 'PPP', 'B')
42
+ rescue Win32::API::LoadLibraryError
43
+ # Windows XP or later
44
+ end
45
+ end
46
+ end
@@ -1,34 +1,34 @@
1
- require 'windows/api'
2
-
3
- # Functions and constants from tlhelp32.h
4
-
5
- module Windows
6
- module ToolHelper
7
- API.auto_namespace = 'Windows::ToolHelper'
8
- API.auto_constant = true
9
- API.auto_method = true
10
- API.auto_unicode = true
11
-
12
- TH32CS_SNAPHEAPLIST = 0x00000001
13
- TH32CS_SNAPPROCESS = 0x00000002
14
- TH32CS_SNAPTHREAD = 0x00000004
15
- TH32CS_SNAPMODULE = 0x00000008
16
- TH32CS_SNAPMODULE32 = 0x00000010
17
- TH32CS_INHERIT = 0x80000000
18
- TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE |
19
- TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
20
-
21
- API.new('CreateToolhelp32Snapshot', 'LL', 'L')
22
- API.new('Heap32First', 'PLL', 'B')
23
- API.new('Heap32ListFirst', 'LP', 'B')
24
- API.new('Heap32ListNext', 'LP', 'B')
25
- API.new('Heap32Next', 'P', 'B')
26
- API.new('Module32First', 'LP', 'B')
27
- API.new('Module32Next', 'LP', 'B')
28
- API.new('Process32First', 'LP', 'B')
29
- API.new('Process32Next', 'LP', 'B')
30
- API.new('Thread32First', 'LP', 'B')
31
- API.new('Thread32Next', 'LP', 'B')
32
- API.new('Toolhelp32ReadProcessMemory', 'LLPLL', 'B')
33
- end
34
- end
1
+ require 'windows/api'
2
+
3
+ # Functions and constants from tlhelp32.h
4
+
5
+ module Windows
6
+ module ToolHelper
7
+ API.auto_namespace = 'Windows::ToolHelper'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = true
11
+
12
+ TH32CS_SNAPHEAPLIST = 0x00000001
13
+ TH32CS_SNAPPROCESS = 0x00000002
14
+ TH32CS_SNAPTHREAD = 0x00000004
15
+ TH32CS_SNAPMODULE = 0x00000008
16
+ TH32CS_SNAPMODULE32 = 0x00000010
17
+ TH32CS_INHERIT = 0x80000000
18
+ TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE |
19
+ TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
20
+
21
+ API.new('CreateToolhelp32Snapshot', 'LL', 'L')
22
+ API.new('Heap32First', 'PLL', 'B')
23
+ API.new('Heap32ListFirst', 'LP', 'B')
24
+ API.new('Heap32ListNext', 'LP', 'B')
25
+ API.new('Heap32Next', 'P', 'B')
26
+ API.new('Module32First', 'LP', 'B')
27
+ API.new('Module32Next', 'LP', 'B')
28
+ API.new('Process32First', 'LP', 'B')
29
+ API.new('Process32Next', 'LP', 'B')
30
+ API.new('Thread32First', 'LP', 'B')
31
+ API.new('Thread32Next', 'LP', 'B')
32
+ API.new('Toolhelp32ReadProcessMemory', 'LLPLL', 'B')
33
+ end
34
+ end
@@ -1,59 +1,59 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module Volume
5
- API.auto_namespace = 'Windows::Volume'
6
- API.auto_constant = true
7
- API.auto_method = true
8
- API.auto_unicode = true
9
-
10
- DRIVE_UNKNOWN = 0
11
- DRIVE_NO_ROOT_DIR = 1
12
- DRIVE_REMOVABLE = 2
13
- DRIVE_FIXED = 3
14
- DRIVE_REMOTE = 4
15
- DRIVE_CDROM = 5
16
- DRIVE_RAMDISK = 6
17
-
18
- API.new('DefineDosDevice', 'LSS', 'B')
19
- API.new('DeleteVolumeMountPoint', 'S', 'B')
20
- API.new('FindFirstVolume', 'PL', 'L')
21
- API.new('FindFirstVolumeMountPoint', 'SPL', 'L')
22
- API.new('FindNextVolume', 'LPL', 'B')
23
- API.new('FindNextVolumeMountPoint', 'LPL', 'B')
24
- API.new('FindVolumeClose', 'L', 'B')
25
- API.new('FindVolumeMountPointClose', 'L', 'B')
26
- API.new('GetDriveType', 'S', 'I')
27
- API.new('GetLogicalDrives', 'V', 'L')
28
- API.new('GetLogicalDriveStrings', 'LP', 'L')
29
- API.new('GetVolumeInformation', 'SPLPPPPL', 'B')
30
- API.new('GetVolumeNameForVolumeMountPoint', 'SPL', 'B')
31
- API.new('GetVolumePathName', 'PPL', 'B')
32
- API.new('QueryDosDevice', 'SPL', 'L')
33
- API.new('SetVolumeLabel', 'SS', 'B')
34
- API.new('SetVolumeMountPoint', 'SS', 'B')
35
-
36
- begin
37
- API.new('GetVolumePathNamesForVolumeName', 'SPLL', 'B')
38
- rescue Win32::API::LoadLibraryError
39
- # Windows XP or later
40
- end
41
-
42
- begin
43
- API.new('GetVolumeInformationByHandleW', 'LPLPPPPL', 'B')
44
- rescue Win32::API::LoadLibraryError
45
- # Windows Vista or later
46
- end
47
-
48
- # Returns the volume type for +vol+ or the volume of the current
49
- # process if no volume is specified.
50
- #
51
- # Returns nil if the function fails for any reason.
52
- #
53
- def get_volume_type(vol = nil)
54
- buf = 0.chr * 256
55
- bool = GetVolumeInformation(vol, nil, nil, nil, nil, nil, buf, buf.size)
56
- bool ? buf.strip : nil
57
- end
58
- end
59
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Volume
5
+ API.auto_namespace = 'Windows::Volume'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
10
+ DRIVE_UNKNOWN = 0
11
+ DRIVE_NO_ROOT_DIR = 1
12
+ DRIVE_REMOVABLE = 2
13
+ DRIVE_FIXED = 3
14
+ DRIVE_REMOTE = 4
15
+ DRIVE_CDROM = 5
16
+ DRIVE_RAMDISK = 6
17
+
18
+ API.new('DefineDosDevice', 'LSS', 'B')
19
+ API.new('DeleteVolumeMountPoint', 'S', 'B')
20
+ API.new('FindFirstVolume', 'PL', 'L')
21
+ API.new('FindFirstVolumeMountPoint', 'SPL', 'L')
22
+ API.new('FindNextVolume', 'LPL', 'B')
23
+ API.new('FindNextVolumeMountPoint', 'LPL', 'B')
24
+ API.new('FindVolumeClose', 'L', 'B')
25
+ API.new('FindVolumeMountPointClose', 'L', 'B')
26
+ API.new('GetDriveType', 'S', 'I')
27
+ API.new('GetLogicalDrives', 'V', 'L')
28
+ API.new('GetLogicalDriveStrings', 'LP', 'L')
29
+ API.new('GetVolumeInformation', 'SPLPPPPL', 'B')
30
+ API.new('GetVolumeNameForVolumeMountPoint', 'SPL', 'B')
31
+ API.new('GetVolumePathName', 'PPL', 'B')
32
+ API.new('QueryDosDevice', 'SPL', 'L')
33
+ API.new('SetVolumeLabel', 'SS', 'B')
34
+ API.new('SetVolumeMountPoint', 'SS', 'B')
35
+
36
+ begin
37
+ API.new('GetVolumePathNamesForVolumeName', 'SPLL', 'B')
38
+ rescue Win32::API::LoadLibraryError
39
+ # Windows XP or later
40
+ end
41
+
42
+ begin
43
+ API.new('GetVolumeInformationByHandleW', 'LPLPPPPL', 'B')
44
+ rescue Win32::API::LoadLibraryError
45
+ # Windows Vista or later
46
+ end
47
+
48
+ # Returns the volume type for +vol+ or the volume of the current
49
+ # process if no volume is specified.
50
+ #
51
+ # Returns nil if the function fails for any reason.
52
+ #
53
+ def get_volume_type(vol = nil)
54
+ buf = 0.chr * 256
55
+ bool = GetVolumeInformation(vol, nil, nil, nil, nil, nil, buf, buf.size)
56
+ bool ? buf.strip : nil
57
+ end
58
+ end
59
+ end
@@ -1,79 +1,79 @@
1
- require 'windows/api'
2
-
3
- # See WinUser.h
4
-
5
- module Windows
6
- module Window
7
- API.auto_namespace = 'Windows::Window'
8
- API.auto_constant = true
9
- API.auto_method = true
10
- API.auto_unicode = false
11
-
12
- # ShowWindow() constants
13
- SW_HIDE = 0
14
- SW_SHOWNORMAL = 1
15
- SW_NORMAL = 1
16
- SW_SHOWMINIMIZED = 2
17
- SW_SHOWMAXIMIZED = 3
18
- SW_MAXIMIZE = 3
19
- SW_SHOWNOACTIVATE = 4
20
- SW_SHOW = 5
21
- SW_MINIMIZE = 6
22
- SW_SHOWMINNOACTIVE = 7
23
- SW_SHOWNA = 8
24
- SW_RESTORE = 9
25
- SW_SHOWDEFAULT = 10
26
- SW_FORCEMINIMIZE = 11
27
- SW_MAX = 11
28
-
29
- API.new('CloseWindow', 'L', 'B', 'user32')
30
- API.new('CreateWindowEx', 'LPPLIIIILLLL', 'L', 'user32')
31
- API.new('EnumWindows', 'KP', 'L', 'user32')
32
- API.new('FindWindow', 'PP', 'L', 'user32')
33
- API.new('FindWindowEx', 'LLPP', 'L', 'user32')
34
- API.new('GetAltTabInfo', 'LIPPI', 'B', 'user32')
35
- API.new('GetAncestor', 'LI', 'L', 'user32')
36
- API.new('GetClientRect', 'LP', 'B', 'user32')
37
- API.new('GetDesktopWindow', 'V', 'L', 'user32')
38
- API.new('GetForegroundWindow', 'V', 'L', 'user32')
39
- API.new('GetGUIThreadInfo', 'LP', 'B', 'user32')
40
- API.new('GetLastActivePopup', 'L', 'L', 'user32')
41
- API.new('GetParent', 'L', 'L', 'user32')
42
- API.new('GetProcessDefaultLayout', 'P', 'B', 'user32')
43
- API.new('GetShellWindow', 'V', 'L', 'user32')
44
- API.new('GetTitleBarInfo', 'LP', 'B', 'user32')
45
- API.new('GetTopWindow', 'L', 'L', 'user32')
46
- API.new('GetWindow', 'LI', 'L', 'user32')
47
- API.new('GetWindowInfo', 'LP', 'B', 'user32')
48
- API.new('GetWindowModuleFileName', 'LLI', 'I', 'user32')
49
- API.new('GetWindowPlacement', 'LP', 'B', 'user32')
50
- API.new('GetWindowRect', 'LP', 'B', 'user32')
51
- API.new('GetWindowText', 'LPI', 'I', 'user32')
52
- API.new('GetWindowTextLength', 'L', 'I', 'user32')
53
- API.new('GetWindowThreadProcessId', 'LP', 'L', 'user32')
54
-
55
- begin
56
- API.new('GetLayeredWindowAttributes', 'LPBL', 'B', 'user32')
57
- rescue Win32::API::LoadLibraryError
58
- # Windows XP or later
59
- end
60
-
61
- # Recent versions of user32.dll turn CreateWindow into a macro for the CreateWindowEx function.
62
- #
63
- begin
64
- API.new('CreateWindow', 'PPLIIIILLLL', 'L', 'user32')
65
- rescue Win32::API::LoadLibraryError
66
- def CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
67
- CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
68
- end
69
-
70
- def CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
71
- CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
72
- end
73
-
74
- def CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
75
- CreateWindowExW(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
76
- end
77
- end
78
- end
79
- end
1
+ require 'windows/api'
2
+
3
+ # See WinUser.h
4
+
5
+ module Windows
6
+ module Window
7
+ API.auto_namespace = 'Windows::Window'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = false
11
+
12
+ # ShowWindow() constants
13
+ SW_HIDE = 0
14
+ SW_SHOWNORMAL = 1
15
+ SW_NORMAL = 1
16
+ SW_SHOWMINIMIZED = 2
17
+ SW_SHOWMAXIMIZED = 3
18
+ SW_MAXIMIZE = 3
19
+ SW_SHOWNOACTIVATE = 4
20
+ SW_SHOW = 5
21
+ SW_MINIMIZE = 6
22
+ SW_SHOWMINNOACTIVE = 7
23
+ SW_SHOWNA = 8
24
+ SW_RESTORE = 9
25
+ SW_SHOWDEFAULT = 10
26
+ SW_FORCEMINIMIZE = 11
27
+ SW_MAX = 11
28
+
29
+ API.new('CloseWindow', 'L', 'B', 'user32')
30
+ API.new('CreateWindowEx', 'LPPLIIIILLLL', 'L', 'user32')
31
+ API.new('EnumWindows', 'KP', 'L', 'user32')
32
+ API.new('FindWindow', 'PP', 'L', 'user32')
33
+ API.new('FindWindowEx', 'LLPP', 'L', 'user32')
34
+ API.new('GetAltTabInfo', 'LIPPI', 'B', 'user32')
35
+ API.new('GetAncestor', 'LI', 'L', 'user32')
36
+ API.new('GetClientRect', 'LP', 'B', 'user32')
37
+ API.new('GetDesktopWindow', 'V', 'L', 'user32')
38
+ API.new('GetForegroundWindow', 'V', 'L', 'user32')
39
+ API.new('GetGUIThreadInfo', 'LP', 'B', 'user32')
40
+ API.new('GetLastActivePopup', 'L', 'L', 'user32')
41
+ API.new('GetParent', 'L', 'L', 'user32')
42
+ API.new('GetProcessDefaultLayout', 'P', 'B', 'user32')
43
+ API.new('GetShellWindow', 'V', 'L', 'user32')
44
+ API.new('GetTitleBarInfo', 'LP', 'B', 'user32')
45
+ API.new('GetTopWindow', 'L', 'L', 'user32')
46
+ API.new('GetWindow', 'LI', 'L', 'user32')
47
+ API.new('GetWindowInfo', 'LP', 'B', 'user32')
48
+ API.new('GetWindowModuleFileName', 'LLI', 'I', 'user32')
49
+ API.new('GetWindowPlacement', 'LP', 'B', 'user32')
50
+ API.new('GetWindowRect', 'LP', 'B', 'user32')
51
+ API.new('GetWindowText', 'LPI', 'I', 'user32')
52
+ API.new('GetWindowTextLength', 'L', 'I', 'user32')
53
+ API.new('GetWindowThreadProcessId', 'LP', 'L', 'user32')
54
+
55
+ begin
56
+ API.new('GetLayeredWindowAttributes', 'LPBL', 'B', 'user32')
57
+ rescue Win32::API::LoadLibraryError
58
+ # Windows XP or later
59
+ end
60
+
61
+ # Recent versions of user32.dll turn CreateWindow into a macro for the CreateWindowEx function.
62
+ #
63
+ begin
64
+ API.new('CreateWindow', 'PPLIIIILLLL', 'L', 'user32')
65
+ rescue Win32::API::LoadLibraryError
66
+ def CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
67
+ CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
68
+ end
69
+
70
+ def CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
71
+ CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
72
+ end
73
+
74
+ def CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
75
+ CreateWindowExW(0, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
76
+ end
77
+ end
78
+ end
79
+ end