windows-pr 0.3.0-mswin32 → 0.4.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/lib/windows/console.rb +323 -0
- data/lib/windows/device_io.rb +0 -69
- data/lib/windows/directory.rb +51 -0
- data/lib/windows/error.rb +6 -25
- data/lib/windows/file.rb +0 -34
- data/lib/windows/library.rb +71 -0
- data/lib/windows/process.rb +155 -0
- data/lib/windows/shell.rb +88 -0
- data/lib/windows/synchronize.rb +111 -11
- data/lib/windows/system_info.rb +64 -0
- data/lib/windows/unicode.rb +106 -0
- data/lib/windows/window.rb +22 -0
- data/test/tc_console.rb +107 -0
- data/test/tc_synchronize.rb +44 -6
- data/test/ts_all.rb +5 -1
- metadata +11 -2
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Process
|
5
|
+
PROCESS_ALL_ACCESS = 0x1F0FFF
|
6
|
+
PROCESS_CREATE_PROCESS = 0x0080
|
7
|
+
PROCESS_CREATE_THREAD = 0x0002
|
8
|
+
PROCESS_DUP_HANDLE = 0x0040
|
9
|
+
PROCESS_QUERY_INFORMATION = 0x0400
|
10
|
+
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
11
|
+
PROCESS_SET_QUOTA = 0x0100
|
12
|
+
PROCESS_SET_INFORMATION = 0x0200
|
13
|
+
PROCESS_SUSPEND_RESUME = 0x0800
|
14
|
+
PROCESS_TERMINATE = 0x0001
|
15
|
+
PROCESS_VM_OPERATION = 0x0008
|
16
|
+
PROCESS_VM_READ = 0x0010
|
17
|
+
PROCESS_VM_WRITE = 0x0020
|
18
|
+
SYNCHRONIZE = 1048576
|
19
|
+
STILL_ACTIVE = 259
|
20
|
+
|
21
|
+
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
|
22
|
+
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
|
23
|
+
HIGH_PRIORITY_CLASS = 0x00000080
|
24
|
+
IDLE_PRIORITY_CLASS = 0x00000040
|
25
|
+
NORMAL_PRIORITY_CLASS = 0x00000020
|
26
|
+
REALTIME_PRIORITY_CLASS = 0x00000100
|
27
|
+
|
28
|
+
# Process creation flags
|
29
|
+
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
|
30
|
+
CREATE_DEFAULT_ERROR_MODE = 0x04000000
|
31
|
+
CREATE_NEW_CONSOLE = 0x00000010
|
32
|
+
CREATE_NEW_PROCESS_GROUP = 0x00000200
|
33
|
+
CREATE_NO_WINDOW = 0x08000000
|
34
|
+
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
|
35
|
+
CREATE_SEPARATE_WOW_VDM = 0x00000800
|
36
|
+
CREATE_SHARED_WOW_VDM = 0x00001000
|
37
|
+
CREATE_SUSPENDED = 0x00000004
|
38
|
+
CREATE_UNICODE_ENVIRONMENT = 0x00000400
|
39
|
+
DEBUG_ONLY_THIS_PROCESS = 0x00000002
|
40
|
+
DEBUG_PROCESS = 0x00000001
|
41
|
+
DETACHED_PROCESS = 0x00000008
|
42
|
+
|
43
|
+
STARTF_USESHOWWINDOW = 0x00000001
|
44
|
+
STARTF_USESIZE = 0x00000002
|
45
|
+
STARTF_USEPOSITION = 0x00000004
|
46
|
+
STARTF_USECOUNTCHARS = 0x00000008
|
47
|
+
STARTF_USEFILLATTRIBUTE = 0x00000010
|
48
|
+
STARTF_RUNFULLSCREEN = 0x00000020
|
49
|
+
STARTF_FORCEONFEEDBACK = 0x00000040
|
50
|
+
STARTF_FORCEOFFFEEDBACK = 0x00000080
|
51
|
+
STARTF_USESTDHANDLES = 0x00000100
|
52
|
+
STARTF_USEHOTKEY = 0x00000200
|
53
|
+
|
54
|
+
CreateProcess = Win32API.new('kernel32', 'CreateProcess', 'LPLLLLLLPP', 'I')
|
55
|
+
CreateRemoteThread = Win32API.new('kernel32', 'CreateRemoteThread', 'LPLLPLP', 'L')
|
56
|
+
ExitProcess = Win32API.new('kernel32', 'ExitProcess', 'L', 'V')
|
57
|
+
GetCommandLine = Win32API.new('kernel32', 'GetCommandLine', 'V', 'P')
|
58
|
+
GetCurrentProcess = Win32API.new('kernel32', 'GetCurrentProcess', 'V', 'L')
|
59
|
+
GetCurrentProcessId = Win32API.new('kernel32', 'GetCurrentProcessId', 'V', 'L')
|
60
|
+
GetEnvironmentStrings = Win32API.new('kernel32', 'GetEnvironmentStrings', 'V', 'L')
|
61
|
+
GetEnvironmentVariable = Win32API.new('kernel32', 'GetEnvironmentVariable', 'PPL', 'L')
|
62
|
+
GetExitCodeProcess = Win32API.new('kernel32', 'GetExitCodeProcess', 'LP', 'I')
|
63
|
+
GetPriorityClass = Win32API.new('kernel32', 'GetPriorityClass', 'L', 'L')
|
64
|
+
GetProcessHandleCount = Win32API.new('kernel32', 'GetProcessHandleCount', 'LP', 'I')
|
65
|
+
GetProcessId = Win32API.new('kernel32', 'GetProcessId', 'L', 'L')
|
66
|
+
GetProcessTimes = Win32API.new('kernel32', 'GetProcessTimes', 'LPPPP', 'I')
|
67
|
+
GetStartupInfo = Win32API.new('kernel32', 'GetStartupInfo', 'P', 'V')
|
68
|
+
OpenProcess = Win32API.new('kernel32', 'OpenProcess', 'LIL', 'L')
|
69
|
+
SetEnvironmentVariable = Win32API.new('kernel32', 'SetEnvironmentVariable', 'PP', 'I')
|
70
|
+
Sleep = Win32API.new('kernel32', 'Sleep', 'L', 'V')
|
71
|
+
SleepEx = Win32API.new('kernel32', 'SleepEx', 'LI', 'L')
|
72
|
+
TerminateProcess = Win32API.new('kernel32', 'TerminateProcess', 'LL', 'I')
|
73
|
+
WaitForInputIdle = Win32API.new('user32', 'WaitForInputIdle', 'LL', 'L')
|
74
|
+
|
75
|
+
def CreateProcess(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo)
|
76
|
+
CreateProcess.call(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo) != 0
|
77
|
+
end
|
78
|
+
|
79
|
+
def CreateRemoteThread(handle, tattr, size, start, param, flags, tid)
|
80
|
+
CreateRemoteThread.call(handle, tattr, size, start, param, flags, tid)
|
81
|
+
end
|
82
|
+
|
83
|
+
def ExitProcess(exit_code)
|
84
|
+
ExitProcess.call(exit_code)
|
85
|
+
end
|
86
|
+
|
87
|
+
def GetCommandLine
|
88
|
+
GetCommandLine.call
|
89
|
+
end
|
90
|
+
|
91
|
+
def GetCurrentProcess()
|
92
|
+
GetCurrentProcess.call
|
93
|
+
end
|
94
|
+
|
95
|
+
def GetCurrentProcessId()
|
96
|
+
GetCurrentProcessId.call
|
97
|
+
end
|
98
|
+
|
99
|
+
def GetEnvironmentStrings()
|
100
|
+
GetEnvironmentStrings.call
|
101
|
+
end
|
102
|
+
|
103
|
+
def GetEnvironmentVariable(name, buffer, size)
|
104
|
+
GetEnvironmentVariable.call(name, buffer, size)
|
105
|
+
end
|
106
|
+
|
107
|
+
def GetExitCodeProcess(handle, exit_code)
|
108
|
+
GetExitCodeProcess.call(handle, exit_code) != 0
|
109
|
+
end
|
110
|
+
|
111
|
+
def GetPriorityClass(handle)
|
112
|
+
GetPriorityClass.call(handle)
|
113
|
+
end
|
114
|
+
|
115
|
+
def GetProcessHandleCount(handle, count)
|
116
|
+
GetProcessHandleCount.call(handle, count) != 0
|
117
|
+
end
|
118
|
+
|
119
|
+
def GetProcessId(handle)
|
120
|
+
GetProcessId.call(handle)
|
121
|
+
end
|
122
|
+
|
123
|
+
def GetProcessTimes(handle, t_creation, t_exit, t_kernel, t_user)
|
124
|
+
GetProcessTimes.call(handle, t_creation, t_exit, t_kernel, t_user) != 0
|
125
|
+
end
|
126
|
+
|
127
|
+
def GetStartupInfo(info_struct)
|
128
|
+
GetStartupInfo.call(info_struct)
|
129
|
+
end
|
130
|
+
|
131
|
+
def OpenProcess(access, handle, pid)
|
132
|
+
OpenProcess.call(access, handle, pid)
|
133
|
+
end
|
134
|
+
|
135
|
+
def SetEnvironmentVariable(name, value)
|
136
|
+
SetEnvironmentVariable.call(name, value)
|
137
|
+
end
|
138
|
+
|
139
|
+
def Sleep(milliseconds)
|
140
|
+
Sleep.call(milliseconds)
|
141
|
+
end
|
142
|
+
|
143
|
+
def SleepEx(milliseconds, alertable)
|
144
|
+
SleepEx.call(milliseconds, alertable)
|
145
|
+
end
|
146
|
+
|
147
|
+
def TerminateProcess(handle, exit_code)
|
148
|
+
TerminateProcess.call(handle, exit_code) != 0
|
149
|
+
end
|
150
|
+
|
151
|
+
def WaitForInputIdle(handle, milliseconds)
|
152
|
+
WaitForInputIdle.call(handle, milliseconds)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Shell
|
5
|
+
# CSIDL constants
|
6
|
+
CSIDL_DESKTOP = 0x0000
|
7
|
+
CSIDL_INTERNET = 0x0001
|
8
|
+
CSIDL_PROGRAMS = 0x0002
|
9
|
+
CSIDL_CONTROLS = 0x0003
|
10
|
+
CSIDL_PRINTERS = 0x0004
|
11
|
+
CSIDL_PERSONAL = 0x0005
|
12
|
+
CSIDL_FAVORITES = 0x0006
|
13
|
+
CSIDL_STARTUP = 0x0007
|
14
|
+
CSIDL_RECENT = 0x0008
|
15
|
+
CSIDL_SENDTO = 0x0009
|
16
|
+
CSIDL_BITBUCKET = 0x000a
|
17
|
+
CSIDL_STARTMENU = 0x000b
|
18
|
+
CSIDL_MYDOCUMENTS = 0x000c
|
19
|
+
CSIDL_MYMUSIC = 0x000d
|
20
|
+
CSIDL_MYVIDEO = 0x000e
|
21
|
+
CSIDL_DESKTOPDIRECTORY = 0x0010
|
22
|
+
CSIDL_DRIVES = 0x0011
|
23
|
+
CSIDL_NETWORK = 0x0012
|
24
|
+
CSIDL_NETHOOD = 0x0013
|
25
|
+
CSIDL_FONTS = 0x0014
|
26
|
+
CSIDL_TEMPLATES = 0x0015
|
27
|
+
CSIDL_COMMON_STARTMENU = 0x0016
|
28
|
+
CSIDL_COMMON_PROGRAMS = 0X0017
|
29
|
+
CSIDL_COMMON_STARTUP = 0x0018
|
30
|
+
CSIDL_COMMON_FAVORITES = 0x001f
|
31
|
+
CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019
|
32
|
+
CSIDL_APPDATA = 0x001a
|
33
|
+
CSIDL_PRINTHOOD = 0x001b
|
34
|
+
CSIDL_LOCAL_APPDATA = 0x001c
|
35
|
+
CSIDL_ALTSTARTUP = 0x001d
|
36
|
+
CSIDL_COMMON_ALTSTARTUP = 0x001e
|
37
|
+
CSIDL_INTERNET_CACHE = 0x0020
|
38
|
+
CSIDL_COOKIES = 0x0021
|
39
|
+
CSIDL_HISTORY = 0x0022
|
40
|
+
CSIDL_COMMON_APPDATA = 0x0023
|
41
|
+
CSIDL_WINDOWS = 0x0024
|
42
|
+
CSIDL_SYSTEM = 0x0025
|
43
|
+
CSIDL_PROGRAM_FILES = 0x0026
|
44
|
+
CSIDL_MYPICTURES = 0x0027
|
45
|
+
CSIDL_PROFILE = 0x0028
|
46
|
+
CSIDL_SYSTEMX86 = 0x0029
|
47
|
+
CSIDL_PROGRAM_FILESX86 = 0x002a
|
48
|
+
CSIDL_PROGRAM_FILES_COMMON = 0x002b
|
49
|
+
CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c
|
50
|
+
CSIDL_COMMON_TEMPLATES = 0x002d
|
51
|
+
CSIDL_COMMON_DOCUMENTS = 0x002e
|
52
|
+
CSIDL_CONNECTIONS = 0x0031
|
53
|
+
CSIDL_COMMON_MUSIC = 0x0035
|
54
|
+
CSIDL_COMMON_PICTURES = 0x0036
|
55
|
+
CSIDL_COMMON_VIDEO = 0x0037
|
56
|
+
CSIDL_RESOURCES = 0x0038
|
57
|
+
CSIDL_RESOURCES_LOCALIZED = 0x0039
|
58
|
+
CSIDL_COMMON_OEM_LINKS = 0x003a
|
59
|
+
CSIDL_CDBURN_AREA = 0x003b
|
60
|
+
CSIDL_COMMON_ADMINTOOLS = 0x002f
|
61
|
+
CSIDL_ADMINTOOLS = 0x0030
|
62
|
+
|
63
|
+
# Return codes
|
64
|
+
S_FALSE = 1
|
65
|
+
E_FAIL = 2147500037
|
66
|
+
E_INVALIDARG = 2147483651
|
67
|
+
|
68
|
+
# Flags
|
69
|
+
SHGFP_TYPE_CURRENT
|
70
|
+
SHGFP_TYPE_DEFAULT
|
71
|
+
|
72
|
+
SHGetFolderPath = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
|
73
|
+
SHGetSpecialFolderLocation = Win32API.new('shell32', 'SHGetSpecialFolderLocation', 'LIP', 'L')
|
74
|
+
SHGetSpecialFolderPath = Win32API.new('shell32', 'SHGetSpecialFolderPath', 'LPLL','L')
|
75
|
+
|
76
|
+
def SHGetFolderPath(handle, folder, token, flags, path)
|
77
|
+
SHGetFolderPath.call(handle, folder, token, flags, path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def SHGetSpecialFolderLocation(handle, folder, pidl)
|
81
|
+
SHGetSpecialFolderLocation.call(handle, folder, pidl)
|
82
|
+
end
|
83
|
+
|
84
|
+
def SHGetSpecialFolderPath(handle, path, folder, create)
|
85
|
+
SHGetSpecialFolderPath.call(handle, path, folder, create)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/windows/synchronize.rb
CHANGED
@@ -16,7 +16,6 @@
|
|
16
16
|
# WaitForSingleObjectEx()
|
17
17
|
# WaitForMultipleObjects()
|
18
18
|
# WaitForMultipleObjectsEx()
|
19
|
-
# WaitForInputIdle()
|
20
19
|
#
|
21
20
|
# Defines the the following constants:
|
22
21
|
#
|
@@ -30,7 +29,7 @@
|
|
30
29
|
#
|
31
30
|
# Add the rest of the synchronization functions.
|
32
31
|
#######################################################################
|
33
|
-
require
|
32
|
+
require 'Win32API'
|
34
33
|
|
35
34
|
module Windows
|
36
35
|
module Synchronize
|
@@ -39,23 +38,124 @@ module Windows
|
|
39
38
|
WAIT_TIMEOUT = 0x102
|
40
39
|
WAIT_ABANDONED = 128
|
41
40
|
WAIT_FAILED = 0xFFFFFFFF
|
41
|
+
|
42
|
+
# Wake mask constants
|
43
|
+
QS_ALLEVENTS = 0x04BF
|
44
|
+
QS_ALLINPUT = 0x04FF
|
45
|
+
QS_ALLPOSTMESSAGE = 0x0100
|
46
|
+
QS_HOTKEY = 0x0080
|
47
|
+
QS_INPUT = 0x407
|
48
|
+
QS_KEY = 0x0001
|
49
|
+
QS_MOUSE = 0x0006
|
50
|
+
QS_MOUSEBUTTON = 0x0004
|
51
|
+
QS_MOUSEMOVE = 0x0002
|
52
|
+
QS_PAINT = 0x0020
|
53
|
+
QS_POSTMESSAGE = 0x0008
|
54
|
+
QS_RAWINPUT = 0x0400
|
55
|
+
QS_SENDMESSAGE = 0x0040
|
56
|
+
QS_TIMER = 0x0010
|
57
|
+
|
58
|
+
# Wait type constants
|
59
|
+
MWMO_ALERTABLE = 0x0002
|
60
|
+
MWMO_INPUTAVAILABLE = 0x0004
|
61
|
+
MWMO_WAITALL = 0x0001
|
62
|
+
|
63
|
+
# Access rights
|
64
|
+
EVENT_ALL_ACCESS = 0x1F0003
|
65
|
+
EVENT_MODIFY_STATE = 0x0002
|
66
|
+
MUTEX_ALL_ACCESS = 0x1F0001
|
67
|
+
MUTEX_MODIFY_STATE = 0x0001
|
68
|
+
SEMAPHORE_ALL_ACCESS = 0x1F0003
|
69
|
+
SEMAPHORE_MODIFY_STATE = 0x0002
|
42
70
|
|
43
71
|
CreateEvent = Win32API.new('kernel32', 'CreateEvent', 'PIIP', 'L')
|
44
72
|
CreateMutex = Win32API.new('kernel32', 'CreateMutex', 'PIP', 'L')
|
45
73
|
CreateSemaphore = Win32API.new('kernel32', 'CreateSemaphore', 'PLLP', 'L')
|
74
|
+
|
75
|
+
GetOverlappedResult = Win32API.new('kernel32', 'GetOverlappedResult', 'LPPI', 'I')
|
46
76
|
|
47
77
|
MsgWaitForMultipleObjects = Win32API.new('user32', 'MsgWaitForMultipleObjects', 'LPILL', 'L')
|
48
78
|
MsgWaitForMultipleObjectsEx = Win32API.new('user32', 'MsgWaitForMultipleObjectsEx', 'LPLLL', 'L')
|
49
79
|
|
50
|
-
OpenEvent
|
51
|
-
OpenMutex
|
52
|
-
OpenSemaphore
|
80
|
+
OpenEvent = Win32API.new('kernel32', 'OpenEvent', 'LIP', 'L')
|
81
|
+
OpenMutex = Win32API.new('kernel32', 'OpenMutex', 'LIP', 'L')
|
82
|
+
OpenSemaphore = Win32API.new('kernel32', 'OpenSemaphore', 'LIP', 'L')
|
83
|
+
ReleaseMutex = Win32API.new('kernel32', 'ReleaseMutex', 'L', 'I')
|
84
|
+
ReleaseSemaphore = Win32API.new('kernel32', 'ReleaseSemaphore', 'LLP', 'I')
|
85
|
+
ResetEvent = Win32API.new('kernel32', 'ResetEvent', 'L', 'I')
|
86
|
+
SetEvent = Win32API.new('kernel32', 'SetEvent', 'L', 'I')
|
53
87
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
88
|
+
WaitForMultipleObjects = Win32API.new('kernel32', 'WaitForMultipleObjects', 'LPIL', 'L')
|
89
|
+
WaitForMultipleObjectsEx = Win32API.new('kernel32', 'WaitForMultipleObjectsEx', 'LPILI', 'L')
|
90
|
+
WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', 'LL', 'L')
|
91
|
+
WaitForSingleObjectEx = Win32API.new('kernel32', 'WaitForSingleObjectEx', 'LLI', 'L')
|
92
|
+
|
93
|
+
def CreateEvent(attributes, reset, state, name)
|
94
|
+
CreateEvent.call(attributes, reset, state, name)
|
95
|
+
end
|
96
|
+
|
97
|
+
def CreateMutex(attributes, owner, name)
|
98
|
+
CreateMutex.call(attributes, owner, name)
|
99
|
+
end
|
100
|
+
|
101
|
+
def CreateSemaphore(attributes, initial, max, name)
|
102
|
+
CreateSemaphore.call(attributes, initial, max, name)
|
103
|
+
end
|
104
|
+
|
105
|
+
def GetOverlappedResult(handle, overlapped, bytes_transferred, wait)
|
106
|
+
GetOverlappedResult.call(handle, overlapped, bytes_transferred, wait)
|
107
|
+
end
|
108
|
+
|
109
|
+
def MsgWaitForMultipleObjects(count, handles, wait, milli, mask)
|
110
|
+
MsgWaitForMultipleObjects.call(count, handles, wait, milli, mask)
|
111
|
+
end
|
112
|
+
|
113
|
+
def MsgWaitForMultipleObjectsEx(count, handles, milli, mask, flags)
|
114
|
+
MsgWaitForMultipleObjectsEx.call(count, handles, milli, mask, flags)
|
115
|
+
end
|
116
|
+
|
117
|
+
def OpenSemaphore(access, handle, name)
|
118
|
+
OpenSemaphore.call(access, handle, name)
|
119
|
+
end
|
120
|
+
|
121
|
+
def OpenMutex(access, handle, name)
|
122
|
+
OpenMutex.call(access, handle, name)
|
123
|
+
end
|
124
|
+
|
125
|
+
def OpenEvent(access, handle, name)
|
126
|
+
OpenEvent.call(access, handle, name)
|
127
|
+
end
|
128
|
+
|
129
|
+
def ReleaseMutex(handle)
|
130
|
+
ReleaseMutex.call(handle) != 0
|
131
|
+
end
|
132
|
+
|
133
|
+
def ReleaseSemaphore(handle, release_count, previous_count)
|
134
|
+
ReleaseSemaphore.call(handle, release_count, previous_count) != 0
|
135
|
+
end
|
136
|
+
|
137
|
+
def ResetEvent(handle)
|
138
|
+
ResetEvent.call(handle) != 0
|
139
|
+
end
|
140
|
+
|
141
|
+
def SetEvent(handle)
|
142
|
+
SetEvent.call(handle) != 0
|
143
|
+
end
|
144
|
+
|
145
|
+
def WaitForMultipleObjects(count, handles, wait_all, milliseconds)
|
146
|
+
WaitForMultipleObjects.call(count, handles, wait_all, milliseconds)
|
147
|
+
end
|
148
|
+
|
149
|
+
def WaitForMultipleObjectsEx(count, handles, wait_all, milliseconds, alertable)
|
150
|
+
WaitForMultipleObjectsEx.call(count, handles, wait_all, milliseconds, alertable)
|
151
|
+
end
|
152
|
+
|
153
|
+
def WaitForSingleObject(handle, milliseconds)
|
154
|
+
WaitForSingleObject.call(handle, milliseconds)
|
155
|
+
end
|
156
|
+
|
157
|
+
def WaitForSingleObjectEx(handle, milliseconds, alertable)
|
158
|
+
WaitForSingleObject.call(handle, milliseconds, alertable)
|
159
|
+
end
|
60
160
|
end
|
61
161
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module SystemInfo
|
5
|
+
# Obsolete processor info constants
|
6
|
+
PROCESSOR_INTEL_386 = 386
|
7
|
+
PROCESSOR_INTEL_486 = 486
|
8
|
+
PROCESSOR_INTEL_PENTIUM = 586
|
9
|
+
PROCESSOR_INTEL_IA64 = 2200
|
10
|
+
PROCESSOR_AMD_X8664 = 8664
|
11
|
+
|
12
|
+
# Enum COMPUTER_NAME_FORMAT
|
13
|
+
ComputerNameNetBIOS = 0
|
14
|
+
ComputerNameDnsHostname = 1
|
15
|
+
ComputerNameDnsDomain = 2
|
16
|
+
ComputerNameDnsFullyQualified = 3
|
17
|
+
ComputerNamePhysicalNetBIOS = 4
|
18
|
+
ComputerNamePhysicalDnsHostname = 5
|
19
|
+
ComputerNamePhysicalDnsDomain = 6
|
20
|
+
ComputerNamePhysicalDnsFullyQualified = 7
|
21
|
+
ComputerNameMax = 8
|
22
|
+
|
23
|
+
GetComputerName = Win32API.new('kernel32', 'GetComputerName', 'PP', 'I')
|
24
|
+
GetComputerNameEx = Win32API.new('kernel32', 'GetComputerNameEx', 'PPP', 'I')
|
25
|
+
GetSystemInfo = Win32API.new('kernel32', 'GetSystemInfo', 'P', 'V')
|
26
|
+
GetUserName = Win32API.new('advapil32', 'GetUserName', 'LL', 'I')
|
27
|
+
GetUserNameEx = Win32API.new('secur32', 'GetUserNameEx', 'LPL', 'I')
|
28
|
+
GetVersion = Win32API.new('kernel32', 'GetVersion', 'V', 'L')
|
29
|
+
GetVersionEx = Win32API.new('kernel32', 'GetVersionEx', 'P', 'I')
|
30
|
+
GetWindowsDirectory = Win32API.new('kernel32', 'GetWindowsDirectory', 'LI', 'I')
|
31
|
+
|
32
|
+
def GetComputerName(buffer, size)
|
33
|
+
GetComputerNameEx.call(buffer, size) != 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def GetComputerNameEx(name, buffer, size)
|
37
|
+
GetComputerNameEx.call(name, buffer, size) != 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def GetSystemInfo(info)
|
41
|
+
GetSystemInfo.call(info)
|
42
|
+
end
|
43
|
+
|
44
|
+
def GetUserName(buf, size)
|
45
|
+
GetUserName.call(buf, size) != 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def GetUserNameEx(format, buf, size)
|
49
|
+
GetUserNameEx.call(format, buf, size) != 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def GetVersion()
|
53
|
+
GetVersion.call
|
54
|
+
end
|
55
|
+
|
56
|
+
def GetVersionEx(info)
|
57
|
+
GetVersionEx.call(info) != 0
|
58
|
+
end
|
59
|
+
|
60
|
+
def GetWindowsDirectory(buf, size)
|
61
|
+
GetWindowsDirectory.call(buf, size)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Unicode
|
5
|
+
CP_ACP = 0
|
6
|
+
CP_OEMCP = 1
|
7
|
+
CP_MACCP = 2
|
8
|
+
CP_THREAD_ACP = 3
|
9
|
+
CP_SYMBOL = 42
|
10
|
+
CP_UTF7 = 65000
|
11
|
+
CP_UTF8 = 65001
|
12
|
+
|
13
|
+
MB_PRECOMPOSED = 0x00000001
|
14
|
+
MB_COMPOSITE = 0x00000002
|
15
|
+
MB_USEGLYPHCHARS = 0x00000004
|
16
|
+
MB_ERR_INVALID_CHARS = 0x00000008
|
17
|
+
|
18
|
+
WC_COMPOSITECHECK = 0x00000200
|
19
|
+
WC_DISCARDNS = 0x00000010
|
20
|
+
WC_SEPCHARS = 0x00000020
|
21
|
+
WC_DEFAULTCHAR = 0x00000040
|
22
|
+
WC_NO_BEST_FIT_CHARS = 0x00000400
|
23
|
+
|
24
|
+
ANSI_CHARSET = 0
|
25
|
+
DEFAULT_CHARSET = 1
|
26
|
+
SYMBOL_CHARSET = 2
|
27
|
+
SHIFTJIS_CHARSET = 128
|
28
|
+
HANGEUL_CHARSET = 129
|
29
|
+
HANGUL_CHARSET = 129
|
30
|
+
GB2312_CHARSET = 134
|
31
|
+
CHINESEBIG5_CHARSET = 136
|
32
|
+
OEM_CHARSET = 255
|
33
|
+
JOHAB_CHARSET = 130
|
34
|
+
HEBREW_CHARSET = 177
|
35
|
+
ARABIC_CHARSET = 178
|
36
|
+
GREEK_CHARSET = 161
|
37
|
+
TURKISH_CHARSET = 162
|
38
|
+
VIETNAMESE_CHARSET = 163
|
39
|
+
THAI_CHARSET = 222
|
40
|
+
EASTEUROPE_CHARSET = 238
|
41
|
+
RUSSIAN_CHARSET = 204
|
42
|
+
|
43
|
+
IS_TEXT_UNICODE_ASCII16 = 0x0001
|
44
|
+
IS_TEXT_UNICODE_REVERSE_ASCII16 = 0x0010
|
45
|
+
IS_TEXT_UNICODE_STATISTICS = 0x0002
|
46
|
+
IS_TEXT_UNICODE_REVERSE_STATISTICS = 0x0020
|
47
|
+
IS_TEXT_UNICODE_CONTROLS = 0x0004
|
48
|
+
IS_TEXT_UNICODE_REVERSE_CONTROLS = 0x0040
|
49
|
+
IS_TEXT_UNICODE_SIGNATURE = 0x0008
|
50
|
+
IS_TEXT_UNICODE_REVERSE_SIGNATURE = 0x0080
|
51
|
+
IS_TEXT_UNICODE_ILLEGAL_CHARS = 0x0100
|
52
|
+
IS_TEXT_UNICODE_ODD_LENGTH = 0x0200
|
53
|
+
IS_TEXT_UNICODE_DBCS_LEADBYTE = 0x0400
|
54
|
+
IS_TEXT_UNICODE_NULL_BYTES = 0x1000
|
55
|
+
IS_TEXT_UNICODE_UNICODE_MASK = 0x000F
|
56
|
+
IS_TEXT_UNICODE_REVERSE_MASK = 0x00F0
|
57
|
+
IS_TEXT_UNICODE_NOT_UNICODE_MASK = 0x0F00
|
58
|
+
IS_TEXT_UNICODE_NOT_ASCII_MASK = 0xF000
|
59
|
+
|
60
|
+
TCI_SRCCHARSET = 1
|
61
|
+
TCI_SRCCODEPAGE = 2
|
62
|
+
TCI_SRCFONTSIG = 3
|
63
|
+
TCI_SRCLOCALE = 0x100
|
64
|
+
|
65
|
+
GetTextCharset = Win32API.new('gdi32', 'GetTextCharset', 'L', 'I')
|
66
|
+
GetTextCharsetInfo = Win32API.new('gdi32', 'GetTextCharsetInfo', 'LPL', 'I')
|
67
|
+
IsDBCSLeadByte = Win32API.new('kernel32', 'IsDBCSLeadByte', 'P', 'I')
|
68
|
+
IsDBCSLeadByteEx = Win32API.new('kernel32', 'IsDBCSLeadByteEx', 'IP', 'I')
|
69
|
+
IsTextUnicode = Win32API.new('advapi32', 'IsTextUnicode', 'PIP', 'I')
|
70
|
+
MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ILPIPI', 'I')
|
71
|
+
TranslateCharsetInfo = Win32API.new('kernel32', 'TranslateCharsetInfo', 'PPL', 'I')
|
72
|
+
WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ILPIPIPP', 'I')
|
73
|
+
|
74
|
+
def GetTextCharset(hdc)
|
75
|
+
GetTextCharset.call(hdc)
|
76
|
+
end
|
77
|
+
|
78
|
+
def GetTextCharsetInfo(hdc, sig, flags)
|
79
|
+
GetTextCharsetInfo.call(hdc, sig, flags)
|
80
|
+
end
|
81
|
+
|
82
|
+
def IsDBCSLeadByte(char)
|
83
|
+
IsDBCSLeadByte.call(char) != 0
|
84
|
+
end
|
85
|
+
|
86
|
+
def IsDBCSLeadByteEx(code_page, char)
|
87
|
+
IsDBCSLeadByteEx.call(code_pag, char) != 0
|
88
|
+
end
|
89
|
+
|
90
|
+
def IsTextUnicode(buf, size, options)
|
91
|
+
IsTextUnicode.call(buf, size, options) != 0
|
92
|
+
end
|
93
|
+
|
94
|
+
def MultiByteToWideChar(page, flags, str, str_size, buf, buf_size)
|
95
|
+
MultiByteToWideChar.call(page, flags, str, str_size, buf, buf_size)
|
96
|
+
end
|
97
|
+
|
98
|
+
def TranslateCharsetInfo(src, cs, flags)
|
99
|
+
TranslateCharsetInfo.call(src, cs, flags) != 0
|
100
|
+
end
|
101
|
+
|
102
|
+
def WideCharToMultiByte(page, flags, str, str_size, buf, buf_size, defchar, used_def)
|
103
|
+
WideCharToMultiByte.call(page, flags, str, str_size, buf, buf_size, defchar, used_def)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Window
|
5
|
+
# ShowWindow() constants
|
6
|
+
SW_HIDE = 0
|
7
|
+
SW_SHOWNORMAL = 1
|
8
|
+
SW_NORMAL = 1
|
9
|
+
SW_SHOWMINIMIZED = 2
|
10
|
+
SW_SHOWMAXIMIZED = 3
|
11
|
+
SW_MAXIMIZE = 3
|
12
|
+
SW_SHOWNOACTIVATE = 4
|
13
|
+
SW_SHOW = 5
|
14
|
+
SW_MINIMIZE = 6
|
15
|
+
SW_SHOWMINNOACTIVE = 7
|
16
|
+
SW_SHOWNA = 8
|
17
|
+
SW_RESTORE = 9
|
18
|
+
SW_SHOWDEFAULT = 10
|
19
|
+
SW_FORCEMINIMIZE = 11
|
20
|
+
SW_MAX = 11
|
21
|
+
end
|
22
|
+
end
|