windows-pr 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/MANIFEST +1 -0
- data/lib/windows/clipboard.rb +17 -52
- data/lib/windows/com.rb +54 -0
- data/lib/windows/console.rb +62 -281
- data/lib/windows/debug.rb +36 -0
- data/lib/windows/device_io.rb +9 -7
- data/lib/windows/directory.rb +20 -75
- data/lib/windows/error.rb +51 -36
- data/lib/windows/eventlog.rb +20 -101
- data/lib/windows/file.rb +59 -295
- data/lib/windows/file_mapping.rb +14 -32
- data/lib/windows/filesystem.rb +8 -10
- data/lib/windows/handle.rb +15 -11
- data/lib/windows/library.rb +21 -63
- data/lib/windows/memory.rb +28 -106
- data/lib/windows/msvcrt/buffer.rb +20 -15
- data/lib/windows/msvcrt/file.rb +38 -7
- data/lib/windows/msvcrt/io.rb +180 -80
- data/lib/windows/msvcrt/string.rb +20 -15
- data/lib/windows/national.rb +16 -39
- data/lib/windows/network_management.rb +93 -92
- data/lib/windows/nio.rb +26 -0
- data/lib/windows/path.rb +68 -349
- data/lib/windows/pipe.rb +18 -56
- data/lib/windows/process.rb +28 -110
- data/lib/windows/registry.rb +27 -142
- data/lib/windows/security.rb +34 -142
- data/lib/windows/service.rb +34 -80
- data/lib/windows/shell.rb +10 -16
- data/lib/windows/sound.rb +17 -31
- data/lib/windows/synchronize.rb +24 -90
- data/lib/windows/system_info.rb +16 -47
- data/lib/windows/unicode.rb +21 -41
- data/lib/windows/volume.rb +23 -83
- data/lib/windows/window.rb +11 -17
- data/windows-pr.gemspec +3 -2
- metadata +17 -5
data/lib/windows/service.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
2
3
|
|
3
4
|
module Windows
|
4
5
|
module Service
|
6
|
+
API.auto_namespace = 'Windows::Service'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
5
11
|
# SCM access rights
|
6
12
|
SC_MANAGER_ALL_ACCESS = 0xF003F
|
7
13
|
SC_MANAGER_CREATE_SERVICE = 0x0002
|
@@ -100,84 +106,32 @@ module Windows
|
|
100
106
|
SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
|
101
107
|
SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
|
102
108
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
def CloseServiceHandle(handle)
|
132
|
-
CloseServiceHandle.call(handle) != 0
|
133
|
-
end
|
134
|
-
|
135
|
-
def ControlService(service, control, status)
|
136
|
-
ControlService.call(service, control, status) != 0
|
137
|
-
end
|
138
|
-
|
139
|
-
def DeleteService(handle)
|
140
|
-
DeleteService.call(handle) != 0
|
141
|
-
end
|
142
|
-
|
143
|
-
def EnumServicesStatusEx(handle, info, s_type, s_state, services, size, bytes, s_returned, rhandle, grp)
|
144
|
-
EnumServicesStatusEx.call(handle, info, s_type, s_state, services, size, bytes, s_returned, rhandle, grp) != 0
|
145
|
-
end
|
146
|
-
|
147
|
-
def GetServiceDisplayName(handle, service, display, buf)
|
148
|
-
GetServiceDisplayName.call(handle, service, display, buf) != 0
|
149
|
-
end
|
150
|
-
|
151
|
-
def GetServiceKeyName(handle, display, service, buf)
|
152
|
-
GetServiceKeyName.call(handle, display, service, buf) != 0
|
153
|
-
end
|
154
|
-
|
155
|
-
def OpenSCManager(host, database, access)
|
156
|
-
OpenSCManager.call(host, database, access)
|
157
|
-
end
|
158
|
-
|
159
|
-
def OpenService(handle, service, access)
|
160
|
-
OpenService.call(handle, service, access)
|
161
|
-
end
|
162
|
-
|
163
|
-
def QueryServiceConfig(handle, buf, buf_size, bytes)
|
164
|
-
QueryServiceConfig.call(handle, buf, buf_size, bytes) != 0
|
165
|
-
end
|
166
|
-
|
167
|
-
def QueryServiceConfig2(handle, info, buf, buf_size, bytes)
|
168
|
-
QueryServiceConfig2.call(handle, info, buf, buf_size, bytes) != 0
|
169
|
-
end
|
170
|
-
|
171
|
-
def QueryServiceStatusEx(service, info, buf, size, bytes)
|
172
|
-
QueryServiceStatusEx.call(service, info, buf, size, bytes) != 0
|
173
|
-
end
|
174
|
-
|
175
|
-
def QueryStatusConfig2(service, info, buf, size, bytes)
|
176
|
-
QueryStatusConfig2.call(service, info, buf, size, bytes) != 0
|
177
|
-
end
|
178
|
-
|
179
|
-
def StartService(handle, num_vec, vec)
|
180
|
-
StartService.call(handle, num_vec, vec)
|
181
|
-
end
|
109
|
+
API.new('ChangeServiceConfig', 'LLLLPPPPPPP', 'B', 'advapi32')
|
110
|
+
API.new('ChangeServiceConfig2', 'LLP', 'B', 'advapi32')
|
111
|
+
API.new('CloseServiceHandle', 'L', 'B', 'advapi32')
|
112
|
+
API.new('ControlService', 'LLP', 'B', 'advapi32')
|
113
|
+
API.new('CreateService', 'LPPLLLLPPPPPP', 'L', 'advapi32')
|
114
|
+
API.new('DeleteService', 'L', 'B', 'advapi32')
|
115
|
+
API.new('EnumDependentServices', 'LLPLPP', 'B', 'advapi32')
|
116
|
+
API.new('EnumServicesStatus', 'LLLPLPPP', 'B', 'advapi32')
|
117
|
+
API.new('EnumServicesStatusEx', 'LLLLPLPPPP', 'B', 'advapi32')
|
118
|
+
API.new('GetServiceDisplayName', 'LPPP', 'B', 'advapi32')
|
119
|
+
API.new('GetServiceKeyName', 'LPPP', 'B', 'advapi32')
|
120
|
+
API.new('LockServiceDatabase', 'L', 'L', 'advapi32')
|
121
|
+
API.new('NotifyBootConfigStatus', 'I', 'B', 'advapi32')
|
122
|
+
API.new('OpenSCManager', 'PPL', 'L', 'advapi32')
|
123
|
+
API.new('OpenService', 'LPL', 'L', 'advapi32')
|
124
|
+
API.new('QueryServiceConfig', 'LPLP', 'B', 'advapi32')
|
125
|
+
API.new('QueryServiceConfig2', 'LLPLP', 'B', 'advapi32')
|
126
|
+
API.new('QueryServiceLockStatus', 'LPLP', 'B', 'advapi32')
|
127
|
+
API.new('QueryServiceStatus', 'LP', 'B', 'advapi32')
|
128
|
+
API.new('QueryServiceStatusEx', 'LLPLP', 'B', 'advapi32')
|
129
|
+
API.new('RegisterServiceCtrlHandler', 'PP', 'L', 'advapi32')
|
130
|
+
API.new('RegisterServiceCtrlHandlerEx', 'PPP', 'L', 'advapi32')
|
131
|
+
API.new('SetServiceBits', 'LLII', 'B', 'advapi32')
|
132
|
+
API.new('SetServiceStatus', 'LP', 'B', 'advapi32')
|
133
|
+
API.new('StartService', 'LLP', 'B', 'advapi32')
|
134
|
+
API.new('StartServiceCtrlDispatcher', 'P', 'B', 'advapi32')
|
135
|
+
API.new('UnlockServiceDatabase', 'L', 'B', 'advapi32')
|
182
136
|
end
|
183
137
|
end
|
data/lib/windows/shell.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
2
3
|
|
3
4
|
module Windows
|
4
5
|
module Shell
|
6
|
+
API.auto_namespace = 'Windows::Shell'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
5
11
|
# CSIDL constants
|
6
12
|
CSIDL_DESKTOP = 0x0000
|
7
13
|
CSIDL_INTERNET = 0x0001
|
@@ -69,20 +75,8 @@ module Windows
|
|
69
75
|
SHGFP_TYPE_CURRENT = 0
|
70
76
|
SHGFP_TYPE_DEFAULT = 1
|
71
77
|
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
78
|
+
API.new('SHGetFolderPath', 'LLLLP', 'L', 'shell32')
|
79
|
+
API.new('SHGetSpecialFolderLocation', 'LIP', 'L', 'shell32')
|
80
|
+
API.new('SHGetSpecialFolderPath', 'LPLL','L', 'shell32')
|
87
81
|
end
|
88
82
|
end
|
data/lib/windows/sound.rb
CHANGED
@@ -1,33 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
# Includes the following functions:
|
5
|
-
#
|
6
|
-
# Beep()
|
7
|
-
# PlaySound()
|
8
|
-
# WaveOutSetVolume()
|
9
|
-
# WaveOutGetVolume()
|
10
|
-
#
|
11
|
-
# Defines the following constants:
|
12
|
-
#
|
13
|
-
# SND_APPLICATION
|
14
|
-
# SND_ALIAS
|
15
|
-
# SND_ALIAS_ID
|
16
|
-
# SND_ASYNC
|
17
|
-
# SND_FILENAME
|
18
|
-
# SND_LOOP
|
19
|
-
# SND_MEMORY
|
20
|
-
# SND_NODEFAULT
|
21
|
-
# SND_NOSTOP
|
22
|
-
# SND_NOWAIT
|
23
|
-
# SND_PURGE
|
24
|
-
# SND_RESOURCE
|
25
|
-
# SND_SYNC
|
26
|
-
##############################################################################
|
27
|
-
require 'Win32API'
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
28
3
|
|
29
4
|
module Windows
|
30
5
|
module Sound
|
6
|
+
API.auto_namespace = 'Windows::Sound'
|
7
|
+
API.auto_constant = false # Because of lowercase method names
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
31
11
|
SND_SYNC = 0x0000 # play synchronously (default)
|
32
12
|
SND_ASYNC = 0x0001 # play asynchronously
|
33
13
|
SND_NODEFAULT = 0x0002 # silence (!default) if sound not found
|
@@ -44,9 +24,15 @@ module Windows
|
|
44
24
|
SND_PURGE = 0x0040 # purge non-static events for task
|
45
25
|
SND_APPLICATION = 0x0080 # look for application specific association
|
46
26
|
|
47
|
-
Beep
|
48
|
-
PlaySound
|
49
|
-
WaveOutSetVolume
|
50
|
-
WaveOutGetVolume
|
27
|
+
Beep = API.new('Beep', 'LL', 'B')
|
28
|
+
PlaySound = API.new('PlaySound', 'PPL', 'B', 'winmm')
|
29
|
+
WaveOutSetVolume = API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
|
30
|
+
WaveOutGetVolume = API.new('waveOutGetVolume', 'IP', 'I', 'winmm')
|
31
|
+
WaveOutGetNumDevs = API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
|
32
|
+
WaveInGetNumDevs = API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
|
33
|
+
MidiOutGetNumDevs = API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
|
34
|
+
MidiInGetNumDevs = API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
|
35
|
+
AuxGetNumDevs = API.new('auxGetNumDevs', 'V', 'I', 'winmm')
|
36
|
+
MixerGetNumDevs = API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
|
51
37
|
end
|
52
38
|
end
|
data/lib/windows/synchronize.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
2
3
|
|
3
4
|
module Windows
|
4
5
|
module Synchronize
|
6
|
+
API.auto_namespace = 'Windows::Synchronize'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
5
11
|
INFINITE = 0xFFFFFFFF
|
6
12
|
WAIT_OBJECT_0 = 0
|
7
13
|
WAIT_TIMEOUT = 0x102
|
@@ -37,94 +43,22 @@ module Windows
|
|
37
43
|
SEMAPHORE_ALL_ACCESS = 0x1F0003
|
38
44
|
SEMAPHORE_MODIFY_STATE = 0x0002
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
WaitForMultipleObjects = Win32API.new('kernel32', 'WaitForMultipleObjects', 'LPIL', 'L')
|
58
|
-
WaitForMultipleObjectsEx = Win32API.new('kernel32', 'WaitForMultipleObjectsEx', 'LPILI', 'L')
|
59
|
-
WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', 'LL', 'L')
|
60
|
-
WaitForSingleObjectEx = Win32API.new('kernel32', 'WaitForSingleObjectEx', 'LLI', 'L')
|
61
|
-
|
62
|
-
def CreateEvent(attributes, reset, state, name)
|
63
|
-
CreateEvent.call(attributes, reset, state, name)
|
64
|
-
end
|
65
|
-
|
66
|
-
def CreateMutex(attributes, owner, name)
|
67
|
-
CreateMutex.call(attributes, owner, name)
|
68
|
-
end
|
69
|
-
|
70
|
-
def CreateSemaphore(attributes, initial, max, name)
|
71
|
-
CreateSemaphore.call(attributes, initial, max, name)
|
72
|
-
end
|
73
|
-
|
74
|
-
def GetOverlappedResult(handle, overlapped, bytes_transferred, wait)
|
75
|
-
GetOverlappedResult.call(handle, overlapped, bytes_transferred, wait)
|
76
|
-
end
|
77
|
-
|
78
|
-
def MsgWaitForMultipleObjects(count, handles, wait, milli, mask)
|
79
|
-
MsgWaitForMultipleObjects.call(count, handles, wait, milli, mask)
|
80
|
-
end
|
81
|
-
|
82
|
-
def MsgWaitForMultipleObjectsEx(count, handles, milli, mask, flags)
|
83
|
-
MsgWaitForMultipleObjectsEx.call(count, handles, milli, mask, flags)
|
84
|
-
end
|
85
|
-
|
86
|
-
def OpenSemaphore(access, handle, name)
|
87
|
-
OpenSemaphore.call(access, handle, name)
|
88
|
-
end
|
89
|
-
|
90
|
-
def OpenMutex(access, handle, name)
|
91
|
-
OpenMutex.call(access, handle, name)
|
92
|
-
end
|
93
|
-
|
94
|
-
def OpenEvent(access, handle, name)
|
95
|
-
OpenEvent.call(access, handle, name)
|
96
|
-
end
|
97
|
-
|
98
|
-
def ReleaseMutex(handle)
|
99
|
-
ReleaseMutex.call(handle) != 0
|
100
|
-
end
|
101
|
-
|
102
|
-
def ReleaseSemaphore(handle, release_count, previous_count)
|
103
|
-
ReleaseSemaphore.call(handle, release_count, previous_count) != 0
|
104
|
-
end
|
105
|
-
|
106
|
-
def ResetEvent(handle)
|
107
|
-
ResetEvent.call(handle) != 0
|
108
|
-
end
|
109
|
-
|
110
|
-
def SetEvent(handle)
|
111
|
-
SetEvent.call(handle) != 0
|
112
|
-
end
|
113
|
-
|
114
|
-
def WaitForMultipleObjects(count, handles, wait_all, milliseconds)
|
115
|
-
WaitForMultipleObjects.call(count, handles, wait_all, milliseconds)
|
116
|
-
end
|
117
|
-
|
118
|
-
def WaitForMultipleObjectsEx(count, handles, wait_all, milliseconds, alertable)
|
119
|
-
WaitForMultipleObjectsEx.call(count, handles, wait_all, milliseconds, alertable)
|
120
|
-
end
|
121
|
-
|
122
|
-
def WaitForSingleObject(handle, milliseconds)
|
123
|
-
WaitForSingleObject.call(handle, milliseconds)
|
124
|
-
end
|
125
|
-
|
126
|
-
def WaitForSingleObjectEx(handle, milliseconds, alertable)
|
127
|
-
WaitForSingleObjectEx.call(handle, milliseconds, alertable)
|
128
|
-
end
|
46
|
+
API.new('CreateEvent', 'PIIP', 'L')
|
47
|
+
API.new('CreateMutex', 'PIP', 'L')
|
48
|
+
API.new('CreateSemaphore', 'PLLP', 'L')
|
49
|
+
API.new('GetOverlappedResult', 'LPPI', 'I')
|
50
|
+
API.new('MsgWaitForMultipleObjects', 'LPILL', 'L', 'user32')
|
51
|
+
API.new('MsgWaitForMultipleObjectsEx', 'LPLLL', 'L', 'user32')
|
52
|
+
API.new('OpenEvent', 'LIP', 'L')
|
53
|
+
API.new('OpenMutex', 'LIP', 'L')
|
54
|
+
API.new('OpenSemaphore', 'LIP', 'L')
|
55
|
+
API.new('ReleaseMutex', 'L', 'B')
|
56
|
+
API.new('ReleaseSemaphore', 'LLP', 'B')
|
57
|
+
API.new('ResetEvent', 'L', 'B')
|
58
|
+
API.new('SetEvent', 'L', 'B')
|
59
|
+
API.new('WaitForMultipleObjects', 'LPIL', 'L')
|
60
|
+
API.new('WaitForMultipleObjectsEx', 'LPILI', 'L')
|
61
|
+
API.new('WaitForSingleObject', 'LL', 'L')
|
62
|
+
API.new('WaitForSingleObjectEx', 'LLI', 'L')
|
129
63
|
end
|
130
64
|
end
|
data/lib/windows/system_info.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
2
3
|
|
3
4
|
module Windows
|
4
5
|
module SystemInfo
|
6
|
+
API.auto_namespace = 'Windows::SystemInfo'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
5
11
|
# Obsolete processor info constants
|
6
12
|
PROCESSOR_INTEL_386 = 386
|
7
13
|
PROCESSOR_INTEL_486 = 486
|
@@ -20,51 +26,14 @@ module Windows
|
|
20
26
|
ComputerNamePhysicalDnsFullyQualified = 7
|
21
27
|
ComputerNameMax = 8
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
GetWindowsDirectory = Win32API.new('kernel32', 'GetWindowsDirectory', 'LI', 'I')
|
33
|
-
|
34
|
-
def ExpandEnvironmentStrings(src, dest, size)
|
35
|
-
ExpandEnvironmentStrings.call(src, dest, size)
|
36
|
-
end
|
37
|
-
|
38
|
-
def GetComputerName(buffer, size)
|
39
|
-
GetComputerName.call(buffer, size) != 0
|
40
|
-
end
|
41
|
-
|
42
|
-
def GetComputerNameEx(name, buffer, size)
|
43
|
-
GetComputerNameEx.call(name, buffer, size) != 0
|
44
|
-
end
|
45
|
-
|
46
|
-
def GetSystemInfo(info)
|
47
|
-
GetSystemInfo.call(info)
|
48
|
-
end
|
49
|
-
|
50
|
-
def GetUserName(buf, size)
|
51
|
-
GetUserName.call(buf, size) != 0
|
52
|
-
end
|
53
|
-
|
54
|
-
def GetUserNameEx(format, buf, size)
|
55
|
-
GetUserNameEx.call(format, buf, size) != 0
|
56
|
-
end
|
57
|
-
|
58
|
-
def GetVersion()
|
59
|
-
GetVersion.call
|
60
|
-
end
|
61
|
-
|
62
|
-
def GetVersionEx(info)
|
63
|
-
GetVersionEx.call(info) != 0
|
64
|
-
end
|
65
|
-
|
66
|
-
def GetWindowsDirectory(buf, size)
|
67
|
-
GetWindowsDirectory.call(buf, size)
|
68
|
-
end
|
29
|
+
API.new('ExpandEnvironmentStrings', 'PPL', 'L')
|
30
|
+
API.new('GetComputerName', 'PP', 'B')
|
31
|
+
API.new('GetComputerNameEx', 'PPP', 'B')
|
32
|
+
API.new('GetSystemInfo', 'P', 'V')
|
33
|
+
API.new('GetUserName', 'PP', 'B', 'advapi32')
|
34
|
+
API.new('GetUserNameEx', 'LPP', 'B', 'secur32')
|
35
|
+
API.new('GetVersion', 'V', 'L')
|
36
|
+
API.new('GetVersionEx', 'P', 'B')
|
37
|
+
API.new('GetWindowsDirectory', 'PI', 'I')
|
69
38
|
end
|
70
39
|
end
|
data/lib/windows/unicode.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'windows/api'
|
2
|
+
include Windows
|
2
3
|
|
3
4
|
module Windows
|
4
5
|
module Unicode
|
6
|
+
API.auto_namespace = 'Windows::Unicode'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = false
|
10
|
+
|
5
11
|
CP_ACP = 0
|
6
12
|
CP_OEMCP = 1
|
7
13
|
CP_MACCP = 2
|
@@ -62,49 +68,23 @@ module Windows
|
|
62
68
|
TCI_SRCFONTSIG = 3
|
63
69
|
TCI_SRCLOCALE = 0x100
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
71
|
+
API.new('GetTextCharset', 'L', 'I', 'gdi32')
|
72
|
+
API.new('GetTextCharsetInfo', 'LPL', 'I', 'gdi32')
|
73
|
+
API.new('IsDBCSLeadByte', 'P', 'B')
|
74
|
+
API.new('IsDBCSLeadByteEx', 'IP', 'B')
|
75
|
+
API.new('IsTextUnicode', 'PIP', 'B', 'advapi32')
|
76
|
+
API.new('MultiByteToWideChar', 'ILPIPI', 'I')
|
77
|
+
API.new('TranslateCharsetInfo', 'PPL', 'B', 'gdi32')
|
78
|
+
API.new('WideCharToMultiByte', 'ILPIPIPP', 'I')
|
89
79
|
|
90
|
-
def IsTextUnicode(buf, size = buf.size, options = 0)
|
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
|
-
|
106
80
|
# Convenient wrapper methods
|
107
81
|
|
82
|
+
# Maps a wide character string to a new character string using the
|
83
|
+
# specified +encoding+. If no encoding is specified, then CP_UTF8
|
84
|
+
# iss used if $KCODE is set to UTF8. Otherwise, CP_ACP is used.
|
85
|
+
#
|
86
|
+
# If the function fails it simply returns the string as-is.
|
87
|
+
#
|
108
88
|
# Maps a string to a wide (unicode) string using +encoding+. If no
|
109
89
|
# encoding is specified, then CP_UTF8 is used if $KCODE is set to UTF8.
|
110
90
|
# Otherwise, CP_ACP is used.
|