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.
- data/CHANGES +408 -404
- data/MANIFEST +65 -65
- data/README +149 -149
- data/Rakefile +52 -52
- data/doc/conversion_guide.txt +37 -37
- data/lib/windows/clipboard.rb +59 -59
- data/lib/windows/com.rb +190 -189
- data/lib/windows/com/automation.rb +147 -147
- data/lib/windows/com/variant.rb +22 -22
- data/lib/windows/console.rb +112 -112
- data/lib/windows/debug.rb +33 -33
- data/lib/windows/device_io.rb +246 -246
- data/lib/windows/directory.rb +25 -25
- data/lib/windows/error.rb +482 -482
- data/lib/windows/eventlog.rb +78 -78
- data/lib/windows/file.rb +262 -262
- data/lib/windows/file_mapping.rb +23 -23
- data/lib/windows/filesystem.rb +13 -13
- data/lib/windows/gdi/bitmap.rb +63 -63
- data/lib/windows/gdi/device_context.rb +44 -44
- data/lib/windows/gdi/metafile.rb +38 -38
- data/lib/windows/gdi/painting_drawing.rb +113 -113
- data/lib/windows/handle.rb +21 -21
- data/lib/windows/library.rb +42 -42
- data/lib/windows/limits.rb +31 -31
- data/lib/windows/mailslot.rb +22 -22
- data/lib/windows/memory.rb +126 -126
- data/lib/windows/msvcrt/buffer.rb +73 -73
- data/lib/windows/msvcrt/directory.rb +29 -29
- data/lib/windows/msvcrt/file.rb +45 -45
- data/lib/windows/msvcrt/io.rb +71 -71
- data/lib/windows/msvcrt/time.rb +167 -167
- data/lib/windows/national.rb +578 -578
- data/lib/windows/network/management.rb +523 -523
- data/lib/windows/network/snmp.rb +90 -90
- data/lib/windows/network/winsock.rb +126 -126
- data/lib/windows/nio.rb +48 -47
- data/lib/windows/ntfs/winternl.rb +96 -96
- data/lib/windows/path.rb +141 -141
- data/lib/windows/pipe.rb +40 -40
- data/lib/windows/process.rb +174 -174
- data/lib/windows/registry.rb +126 -126
- data/lib/windows/security.rb +477 -477
- data/lib/windows/security/authentication.rb +30 -30
- data/lib/windows/service.rb +140 -140
- data/lib/windows/shell.rb +169 -169
- data/lib/windows/sound.rb +37 -37
- data/lib/windows/synchronize.rb +131 -131
- data/lib/windows/system_info.rb +227 -222
- data/lib/windows/thread.rb +62 -62
- data/lib/windows/time.rb +46 -46
- data/lib/windows/tool_helper.rb +34 -34
- data/lib/windows/volume.rb +59 -59
- data/lib/windows/window.rb +79 -79
- data/lib/windows/window/classes.rb +57 -57
- data/lib/windows/window/dialog.rb +89 -89
- data/lib/windows/window/menu.rb +100 -100
- data/lib/windows/window/message.rb +295 -295
- data/lib/windows/window/properties.rb +18 -18
- data/lib/windows/window/timer.rb +17 -17
- data/test/tc_clipboard.rb +41 -41
- data/test/tc_com.rb +32 -32
- data/test/tc_com_automation.rb +15 -15
- data/test/tc_console.rb +108 -108
- data/test/tc_debug.rb +48 -48
- data/test/tc_device_io.rb +29 -29
- data/test/tc_directory.rb +25 -25
- data/test/tc_error.rb +49 -49
- data/test/tc_eventlog.rb +58 -58
- data/test/tc_file.rb +67 -67
- data/test/tc_file_mapping.rb +38 -38
- data/test/tc_filesystem.rb +27 -27
- data/test/tc_gdi_bitmap.rb +25 -25
- data/test/tc_gdi_metafile.rb +23 -23
- data/test/tc_handle.rb +36 -36
- data/test/tc_library.rb +37 -37
- data/test/tc_limits.rb +34 -34
- data/test/tc_mailslot.rb +22 -22
- data/test/tc_memory.rb +44 -44
- data/test/tc_msvcrt_buffer.rb +68 -68
- data/test/tc_msvcrt_directory.rb +98 -98
- data/test/tc_msvcrt_file.rb +80 -80
- data/test/tc_msvcrt_io.rb +48 -48
- data/test/tc_msvcrt_string.rb +93 -93
- data/test/tc_msvcrt_time.rb +29 -29
- data/test/tc_national.rb +38 -38
- data/test/tc_network_management.rb +32 -32
- data/test/tc_network_snmp.rb +31 -31
- data/test/tc_network_winsock.rb +34 -34
- data/test/tc_nio.rb +32 -32
- data/test/tc_ntfs_winternl.rb +29 -29
- data/test/tc_path.rb +90 -90
- data/test/tc_pipe.rb +53 -53
- data/test/tc_process.rb +24 -24
- data/test/tc_registry.rb +29 -29
- data/test/tc_security.rb +104 -104
- data/test/tc_security_authentication.rb +34 -34
- data/test/tc_service.rb +57 -57
- data/test/tc_shell.rb +34 -34
- data/test/tc_sound.rb +37 -37
- data/test/tc_synchronize.rb +75 -75
- data/test/tc_system_info.rb +43 -43
- data/test/tc_thread.rb +29 -29
- data/test/tc_time.rb +32 -32
- data/test/tc_tool_helper.rb +29 -29
- data/test/tc_volume.rb +47 -47
- data/test/tc_window.rb +45 -45
- data/test/tc_window_classes.rb +33 -33
- data/test/tc_window_dialog.rb +33 -33
- data/test/tc_window_menu.rb +29 -29
- data/test/tc_window_message.rb +33 -33
- data/test/tc_window_properties.rb +29 -29
- data/test/tc_window_timer.rb +29 -29
- data/windows-pr.gemspec +34 -34
- metadata +4 -4
data/lib/windows/thread.rb
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
data/lib/windows/tool_helper.rb
CHANGED
@@ -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
|
data/lib/windows/volume.rb
CHANGED
@@ -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
|
data/lib/windows/window.rb
CHANGED
@@ -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
|