windows-pr 0.6.6 → 0.7.0

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.
@@ -1,7 +1,13 @@
1
- require 'Win32API'
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
- ChangeServiceConfig = Win32API.new('advapi32', 'ChangeServiceConfig', 'LLLLPPPPPPP', 'I')
104
- ChangeServiceConfig2 = Win32API.new('advapi32', 'ChangeServiceConfig2', 'LLP', 'I')
105
- CloseServiceHandle = Win32API.new('advapi32', 'CloseServiceHandle', 'L', 'I')
106
- ControlService = Win32API.new('advapi32', 'ControlService', 'LLP', 'I')
107
- CreateService = Win32API.new('advapi32', 'CreateService', 'LPPLLLLPPPPPP', 'L')
108
- DeleteService = Win32API.new('advapi32', 'DeleteService', 'L', 'I')
109
- EnumDependentServices = Win32API.new('advapi32', 'EnumDependentServices', 'LLPLPP', 'I')
110
- EnumServicesStatus = Win32API.new('advapi32', 'EnumServicesStatus', 'LLLPLPPP', 'I')
111
- EnumServicesStatusEx = Win32API.new('advapi32', 'EnumServicesStatusEx', 'LLLLPLPPPP', 'I')
112
- GetServiceDisplayName = Win32API.new('advapi32', 'GetServiceDisplayName', 'LPPP', 'I')
113
- GetServiceKeyName = Win32API.new('advapi32', 'GetServiceKeyName', 'LPPP', 'I')
114
- LockServiceDatabase = Win32API.new('advapi32', 'LockServiceDatabase', 'L', 'L')
115
- NotifyBootConfigStatus = Win32API.new('advapi32', 'NotifyBootConfigStatus', 'I', 'I')
116
- OpenSCManager = Win32API.new('advapi32', 'OpenSCManager', 'PPL', 'L')
117
- OpenService = Win32API.new('advapi32', 'OpenService', 'LPL', 'L')
118
- QueryServiceConfig = Win32API.new('advapi32', 'QueryServiceConfig', 'LPLP', 'I')
119
- QueryServiceConfig2 = Win32API.new('advapi32', 'QueryServiceConfig2', 'LLPLP', 'I')
120
- QueryServiceLockStatus = Win32API.new('advapi32', 'QueryServiceLockStatus', 'LPLP', 'I')
121
- QueryServiceStatus = Win32API.new('advapi32', 'QueryServiceStatus', 'LP', 'I')
122
- QueryServiceStatusEx = Win32API.new('advapi32', 'QueryServiceStatusEx', 'LLPLP', 'I')
123
- RegisterServiceCtrlHandler = Win32API.new('advapi32', 'RegisterServiceCtrlHandler', 'PP', 'L')
124
- RegisterServiceCtrlHandlerEx = Win32API.new('advapi32', 'RegisterServiceCtrlHandlerEx', 'PPP', 'L')
125
- SetServiceBits = Win32API.new('advapi32', 'SetServiceBits', 'LLII', 'I')
126
- SetServiceStatus = Win32API.new('advapi32', 'SetServiceStatus', 'LP', 'I')
127
- StartService = Win32API.new('advapi32', 'StartService', 'LLP', 'I')
128
- StartServiceCtrlDispatcher = Win32API.new('advapi32', 'StartServiceCtrlDispatcher', 'P', 'I')
129
- UnlockServiceDatabase = Win32API.new('advapi32', 'UnlockServiceDatabase', 'L', 'I')
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 'Win32API'
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
- 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
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
- # sound.rb
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 = Win32API.new('kernel32', 'Beep', 'LL', 'I')
48
- PlaySound = Win32API.new('winmm', 'PlaySound', 'PPL', 'I')
49
- WaveOutSetVolume = Win32API.new('winmm', 'waveOutSetVolume', 'PL', 'I')
50
- WaveOutGetVolume = Win32API.new('winmm', 'waveOutGetVolume', 'IP', 'I')
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
@@ -1,7 +1,13 @@
1
- require 'Win32API'
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
- CreateEvent = Win32API.new('kernel32', 'CreateEvent', 'PIIP', 'L')
41
- CreateMutex = Win32API.new('kernel32', 'CreateMutex', 'PIP', 'L')
42
- CreateSemaphore = Win32API.new('kernel32', 'CreateSemaphore', 'PLLP', 'L')
43
-
44
- GetOverlappedResult = Win32API.new('kernel32', 'GetOverlappedResult', 'LPPI', 'I')
45
-
46
- MsgWaitForMultipleObjects = Win32API.new('user32', 'MsgWaitForMultipleObjects', 'LPILL', 'L')
47
- MsgWaitForMultipleObjectsEx = Win32API.new('user32', 'MsgWaitForMultipleObjectsEx', 'LPLLL', 'L')
48
-
49
- OpenEvent = Win32API.new('kernel32', 'OpenEvent', 'LIP', 'L')
50
- OpenMutex = Win32API.new('kernel32', 'OpenMutex', 'LIP', 'L')
51
- OpenSemaphore = Win32API.new('kernel32', 'OpenSemaphore', 'LIP', 'L')
52
- ReleaseMutex = Win32API.new('kernel32', 'ReleaseMutex', 'L', 'I')
53
- ReleaseSemaphore = Win32API.new('kernel32', 'ReleaseSemaphore', 'LLP', 'I')
54
- ResetEvent = Win32API.new('kernel32', 'ResetEvent', 'L', 'I')
55
- SetEvent = Win32API.new('kernel32', 'SetEvent', 'L', 'I')
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
@@ -1,7 +1,13 @@
1
- require 'Win32API'
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
- ExpandEnvironmentStrings = Win32API.new('kernel32', 'ExpandEnvironmentStrings', 'PPL', 'L')
24
-
25
- GetComputerName = Win32API.new('kernel32', 'GetComputerName', 'PP', 'I')
26
- GetComputerNameEx = Win32API.new('kernel32', 'GetComputerNameEx', 'PPP', 'I')
27
- GetSystemInfo = Win32API.new('kernel32', 'GetSystemInfo', 'P', 'V')
28
- GetUserName = Win32API.new('advapi32', 'GetUserName', 'PP', 'I')
29
- GetUserNameEx = Win32API.new('secur32', 'GetUserNameEx', 'LPP', 'I')
30
- GetVersion = Win32API.new('kernel32', 'GetVersion', 'V', 'L')
31
- GetVersionEx = Win32API.new('kernel32', 'GetVersionEx', 'P', 'I')
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
@@ -1,7 +1,13 @@
1
- require 'Win32API'
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
- 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('gdi32', '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
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.