windows-pr 0.3.0-mswin32

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.
data/CHANGES ADDED
@@ -0,0 +1,11 @@
1
+ = 0.3.0 - 22-Apr-2006
2
+ * Added the limits module.
3
+ * Added the security module.
4
+ * Fixed a signature bug in the msvcrt/buffer module.
5
+
6
+ = 0.2.0 - 13-Apr-2006
7
+ * Added the filesystem module.
8
+ * Fixed signature and dll mistakes in the file module.
9
+
10
+ = 0.1.0 - 4-Apr-2006
11
+ * Initial release
data/MANIFEST ADDED
@@ -0,0 +1,23 @@
1
+ CHANGES
2
+ MANIFEST
3
+ README
4
+ install.rb
5
+ windows-pr.gemspec
6
+
7
+ doc/conversion_guide.txt
8
+
9
+ lib/windows/clipboard.rb
10
+ lib/windows/device_io.rb
11
+ lib/windows/error.rb
12
+ lib/windows/file.rb
13
+ lib/windows/filesystem.rb
14
+ lib/windows/handle.rb
15
+ lib/windows/limits.rb
16
+ lib/windows/memory.rb
17
+ lib/windows/path.rb
18
+ lib/windows/security.rb
19
+ lib/windows/sound.rb
20
+ lib/windows/synchronize.rb
21
+
22
+ lib/windows/msvcrt/buffer.rb
23
+ lib/windows/msvcrt/file.rb
data/README ADDED
@@ -0,0 +1,117 @@
1
+ = windows-pr
2
+ == Description
3
+ A collection of Windows functions predefined for you via Win32API. Hence,
4
+ the 'pr', for 'Pure Ruby'.
5
+
6
+ == Synopsis
7
+ require 'windows/path'
8
+
9
+ class Foo
10
+ include Windows::Path
11
+
12
+ if PathIsRoot.call("C:\\") > 0
13
+ ...
14
+ end
15
+
16
+ # or
17
+
18
+ if PathIsRoot("C:\\")
19
+ ...
20
+ end
21
+ end
22
+
23
+ == Methods
24
+ Each of the various files included as part of this package provide a series
25
+ of constants corresponding to the equivalent Windows API function and
26
+ related numeric constants. For example, if you require 'windows/path',
27
+ you now have PathIsRoot, PathIsUNC, etc, available to you as Win32API
28
+ objects in the form of constants.
29
+
30
+ A wrapper has been provided for each method in order to avoid the
31
+ Win32API#call method. So, instead of PathIsRoot.call(path) you can
32
+ invoke it as PathIsRoot(path). If the original function is lower case
33
+ then the wrapper method is lower case as well. For example, instead of
34
+ doing 'Memcpy.call(dest, src, size)' you can do 'memcpy(dest, src, size)'.
35
+
36
+ Remember boys and girls, if you write PathIsRoot, you're referring to
37
+ the constant. If you write PathIsRoot(), you're calling the wrapper
38
+ method.
39
+
40
+ Boolean methods automatically perform a check for success or failure. So,
41
+ instead of having to do something like 'if PathIsRoot(path) > 0' you can
42
+ just do 'if PathIsRoot(path)'.
43
+
44
+ Files contain related functions, by topic. For example, the clipboard.rb
45
+ file contains clipboard related functions, such as CloseClipboard(), as
46
+ well as constants such as CF_TEXT, CF_BITMAP, etc.
47
+
48
+ == Where are the tests, dude?
49
+ While I've made some effort to test these functions, there are simply too
50
+ many for me to effectively test them all. We're ultimately talking about
51
+ hundreds, if not thousands, of functions, and I don't know what all of them
52
+ actually do. That being said, I will add tests where and when I can.
53
+
54
+ If you find that I've declared the function prototype wrong for a given
55
+ function, please let me know ASAP and I'll fix it. An example program
56
+ demonstrating the problem would be helpful, too. Or, if you'd just like
57
+ to contribute some test cases, that's fine as well.
58
+
59
+ == What's the point?
60
+ I became tired of redefining Windows functions over and over whenever I
61
+ wanted to use the Win32API package. I thought it would be very handy to
62
+ have them predefined for me in a package with convenient wrapper methods
63
+ to boot.
64
+
65
+ While it's true that Moonwolf has a package on the RAA that includes many
66
+ of these functions defined already, there are a few issues with it. First,
67
+ it puts *every* function and constant in one or two files. That's a waste
68
+ of memory, hard to organize & maintain, and impossible to test. Second,
69
+ some of his function declarations are wrong. Third, some of the functions
70
+ I needed for my own projects are missing. Fourth, there's no gem. Lastly,
71
+ I haven't seen an update in over 5 years, which leads me to believe it is
72
+ no longer maintained.
73
+
74
+ == Hey, I'm missing function X!
75
+ I have only defined a small subset of the overall Windows API. It would
76
+ take me years to define them *all*. I defined the ones I needed first,
77
+ plus some that I thought would be useful to others. I will continue to
78
+ add functions in my spare time, or (especially) by request.
79
+
80
+ == Bugs
81
+ None that I'm aware of. Please report any bugs on the project page at
82
+ http://www.rubyforge.org/projects/win32utils.
83
+
84
+ The only real bugs you could find are either bad prototype declarations
85
+ or bad constant values. But, please report either.
86
+
87
+ == Known Issues
88
+ In some cases the MSDN docs are wrong, and we have to learn it the hard
89
+ way. If you should happen to find a documentation bug on their site,
90
+ please contact them and let them know. They're generally good about fixing
91
+ them.
92
+
93
+ In other cases library functions are not exported by the dll. For example,
94
+ my version of shlwapi.dll does not export the PathIsHTMLFile() function,
95
+ despite being well past the minimum version for that dll file. There is
96
+ nothing you or I can do about it short of rebuilding the dll file from
97
+ scratch and/or reporting the issue to Microsoft.
98
+
99
+ == Supported Platforms
100
+ I only support the Windows NT familiy of Windows, and really only Windows
101
+ 2000 and later, though I'll make an effort to support NT 4 if there are
102
+ any NT 4 related issues and requests to support it.
103
+
104
+ == License
105
+ Ruby's
106
+
107
+ == Warranty
108
+ This package is provided "as is" and without any express or
109
+ implied warranties, including, without limitation, the implied
110
+ warranties of merchantability and fitness for a particular purpose.
111
+
112
+ == Copyright
113
+ (C) 2006, Daniel J. Berger
114
+ All Rights Reserved
115
+
116
+ == Author
117
+ Daniel Berger
@@ -0,0 +1,25 @@
1
+ = Parameters
2
+ Long: 'N' or 'L'
3
+ Integer: 'I'
4
+ Pointer: 'P'
5
+ Void: 'V'
6
+
7
+ = Windows Data Types
8
+ BOOL => 'I'
9
+ DWORD => 'L'
10
+ HANDLE => 'L'
11
+ LPDWORD => 'P'
12
+ LPTSTR => 'P'
13
+ UINT => 'I'
14
+ VOID => 'V'
15
+ WORD => 'I'
16
+
17
+ = C Data Types
18
+ void => 'V'
19
+ void* => 'P'
20
+ char* => 'P'
21
+ const char* => 'L'
22
+ int => 'I'
23
+ long => 'L'
24
+ struct => 'P'
25
+ struct* => 'P'
@@ -0,0 +1,105 @@
1
+ #############################################################################
2
+ # clipboard.rb
3
+ #
4
+ # Includes the following functions:
5
+ #
6
+ # CloseClipboard()
7
+ # CoundClipboardFormats()
8
+ # EmptyClipboard()
9
+ # EnumClipboardFormats()
10
+ # GetClipboardData()
11
+ # GetClipboardFormatName()
12
+ # IsClipboardFormatAvailable()
13
+ # OpenClipboard()
14
+ # RegisterClipboardFormat()
15
+ # SetClipboardData()
16
+ #
17
+ # Defines the following constants:
18
+ #
19
+ # CF_TEXT
20
+ # CF_BITMAP
21
+ # CF_METAFILEPICT
22
+ # CF_SYLK
23
+ # CF_DIF
24
+ # CF_TIFF
25
+ # CF_OEMTEXT
26
+ # CF_DIB
27
+ # CF_PALETTE
28
+ # CF_PENDATA
29
+ # CF_RIFF
30
+ # CF_WAVE
31
+ # CF_UNICODETEXT
32
+ # CF_ENHMETAFILE
33
+ #############################################################################
34
+ require 'Win32API'
35
+
36
+ module Windows
37
+ module Clipboard
38
+ CF_TEXT = 1
39
+ CF_BITMAP = 2
40
+ CF_METAFILEPICT = 3
41
+ CF_SYLK = 4
42
+ CF_DIF = 5
43
+ CF_TIFF = 6
44
+ CF_OEMTEXT = 7
45
+ CF_DIB = 8
46
+ CF_PALETTE = 9
47
+ CF_PENDATA = 10
48
+ CF_RIFF = 11
49
+ CF_WAVE = 12
50
+ CF_UNICODETEXT = 13
51
+ CF_ENHMETAFILE = 14
52
+
53
+ OpenClipboard = Win32API.new('user32', 'OpenClipboard', 'L', 'I')
54
+ CloseClipboard = Win32API.new('user32', 'CloseClipboard', 'V', 'I')
55
+ GetClipboardData = Win32API.new('user32', 'GetClipboardData', 'I', 'P')
56
+ EmptyClipboard = Win32API.new('user32', 'EmptyClipboard', 'V', 'I')
57
+ SetClipboardData = Win32API.new('user32', 'SetClipboardData', 'II', 'I')
58
+
59
+ CountClipboardFormats = Win32API.new('user32', 'CountClipboardFormats', 'V', 'I')
60
+ IsClipboardFormatAvailable = Win32API.new('user32', 'IsClipboardFormatAvailable', 'I', 'I')
61
+ GetClipboardFormatName = Win32API.new('user32', 'GetClipboardFormatName', 'IPI', 'I')
62
+ EnumClipboardFormats = Win32API.new('user32', 'EnumClipboardFormats', 'I', 'I')
63
+ RegisterClipboardFormat = Win32API.new('user32', 'RegisterClipboardFormat', 'P', 'I')
64
+
65
+ def OpenClipboard(handle)
66
+ OpenClipboard.call(handle) > 0
67
+ end
68
+
69
+ def CloseClipboard
70
+ CloseClipboard.call > 0
71
+ end
72
+
73
+ def GetClipboardData(format)
74
+ GetClipboardData.call(format)
75
+ end
76
+
77
+ def EmptyClipboard
78
+ EmptyClipboard.call > 0
79
+ end
80
+
81
+ def SetClipboardData(format, handle)
82
+ SetClipboardData.call(format, handle)
83
+ end
84
+
85
+ def CountClipboardFormats
86
+ CountClipboardFormats.call
87
+ end
88
+
89
+ def IsClipboardFormatAvailable(format)
90
+ IsClipboardFormatAvailable.call(format) > 0
91
+ end
92
+
93
+ def GetClipboardFormatName(format, format_name, max)
94
+ GetClipboardFormatName.call(format, format_name, max)
95
+ end
96
+
97
+ def EnumClipboardFormats(format)
98
+ EnumClipboardFormats.call(format)
99
+ end
100
+
101
+ def RegisterClipboardFormat(format)
102
+ RegisterClipboardFormat.call(format)
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,141 @@
1
+ #####################################################################
2
+ # device_io.rb
3
+ #
4
+ # Defines the following functions:
5
+ #
6
+ # DeviceIoControl()
7
+ #
8
+ # Defines the following constants:
9
+ #
10
+ # FILE_DEVICE_BEEP = 0x00000001
11
+ # FILE_DEVICE_CD_ROM = 0x00000002
12
+ # FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003
13
+ # FILE_DEVICE_CONTROLLER = 0x00000004
14
+ # FILE_DEVICE_DATALINK = 0x00000005
15
+ # FILE_DEVICE_DFS = 0x00000006
16
+ # FILE_DEVICE_DISK = 0x00000007
17
+ # FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008
18
+ # FILE_DEVICE_FILE_SYSTEM = 0x00000009
19
+ # FILE_DEVICE_INPORT_PORT = 0x0000000a
20
+ # FILE_DEVICE_KEYBOARD = 0x0000000b
21
+ # FILE_DEVICE_MAILSLOT = 0x0000000c
22
+ # FILE_DEVICE_MIDI_IN = 0x0000000d
23
+ # FILE_DEVICE_MIDI_OUT = 0x0000000e
24
+ # FILE_DEVICE_MOUSE = 0x0000000f
25
+ # FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010
26
+ # FILE_DEVICE_NAMED_PIPE = 0x00000011
27
+ # FILE_DEVICE_NETWORK = 0x00000012
28
+ # FILE_DEVICE_NETWORK_BROWSER = 0x00000013
29
+ # FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
30
+ # FILE_DEVICE_NULL = 0x00000015
31
+ # FILE_DEVICE_PARALLEL_PORT = 0x00000016
32
+ # FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017
33
+ # FILE_DEVICE_PRINTER = 0x00000018
34
+ # FILE_DEVICE_SCANNER = 0x00000019
35
+ # FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001a
36
+ # FILE_DEVICE_SERIAL_PORT = 0x0000001b
37
+ # FILE_DEVICE_SCREEN = 0x0000001c
38
+ # FILE_DEVICE_SOUND = 0x0000001d
39
+ # FILE_DEVICE_STREAMS = 0x0000001e
40
+ # FILE_DEVICE_TAPE = 0x0000001f
41
+ # FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020
42
+ # FILE_DEVICE_TRANSPORT = 0x00000021
43
+ # FILE_DEVICE_UNKNOWN = 0x00000022
44
+ # FILE_DEVICE_VIDEO = 0x00000023
45
+ # FILE_DEVICE_VIRTUAL_DISK = 0x00000024
46
+ # FILE_DEVICE_WAVE_IN = 0x00000025
47
+ # FILE_DEVICE_WAVE_OUT = 0x00000026
48
+ # FILE_DEVICE_8042_PORT = 0x00000027
49
+ # FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028
50
+ # FILE_DEVICE_BATTERY = 0x00000029
51
+ # FILE_DEVICE_BUS_EXTENDER = 0x0000002a
52
+ # FILE_DEVICE_MODEM = 0x0000002b
53
+ # FILE_DEVICE_VDM = 0x0000002c
54
+ # FILE_DEVICE_MASS_STORAGE = 0x0000002d
55
+ # FILE_DEVICE_SMB = 0x0000002e
56
+ # FILE_DEVICE_KS = 0x0000002f
57
+ # FILE_DEVICE_CHANGER = 0x00000030
58
+ # FILE_DEVICE_SMARTCARD = 0x00000031
59
+ # FILE_DEVICE_ACPI = 0x00000032
60
+ # FILE_DEVICE_DVD = 0x00000033
61
+ # FILE_DEVICE_FULLSCREEN_VIDEO = 0x00000034
62
+ # FILE_DEVICE_DFS_FILE_SYSTEM = 0x00000035
63
+ # FILE_DEVICE_DFS_VOLUME = 0x00000036
64
+ # FILE_DEVICE_SERENUM = 0x00000037
65
+ # FILE_DEVICE_TERMSRV = 0x00000038
66
+ # FILE_DEVICE_KSEC = 0x00000039
67
+ # FILE_DEVICE_FIPS = 0x0000003A
68
+ # FILE_DEVICE_INFINIBAND = 0x0000003B
69
+ #####################################################################
70
+ require 'Win32API'
71
+
72
+ module Windows
73
+ module DeviceIO
74
+ # Device Types
75
+ FILE_DEVICE_BEEP = 0x00000001
76
+ FILE_DEVICE_CD_ROM = 0x00000002
77
+ FILE_DEVICE_CD_ROM_FILE_SYSTEM = 0x00000003
78
+ FILE_DEVICE_CONTROLLER = 0x00000004
79
+ FILE_DEVICE_DATALINK = 0x00000005
80
+ FILE_DEVICE_DFS = 0x00000006
81
+ FILE_DEVICE_DISK = 0x00000007
82
+ FILE_DEVICE_DISK_FILE_SYSTEM = 0x00000008
83
+ FILE_DEVICE_FILE_SYSTEM = 0x00000009
84
+ FILE_DEVICE_INPORT_PORT = 0x0000000a
85
+ FILE_DEVICE_KEYBOARD = 0x0000000b
86
+ FILE_DEVICE_MAILSLOT = 0x0000000c
87
+ FILE_DEVICE_MIDI_IN = 0x0000000d
88
+ FILE_DEVICE_MIDI_OUT = 0x0000000e
89
+ FILE_DEVICE_MOUSE = 0x0000000f
90
+ FILE_DEVICE_MULTI_UNC_PROVIDER = 0x00000010
91
+ FILE_DEVICE_NAMED_PIPE = 0x00000011
92
+ FILE_DEVICE_NETWORK = 0x00000012
93
+ FILE_DEVICE_NETWORK_BROWSER = 0x00000013
94
+ FILE_DEVICE_NETWORK_FILE_SYSTEM = 0x00000014
95
+ FILE_DEVICE_NULL = 0x00000015
96
+ FILE_DEVICE_PARALLEL_PORT = 0x00000016
97
+ FILE_DEVICE_PHYSICAL_NETCARD = 0x00000017
98
+ FILE_DEVICE_PRINTER = 0x00000018
99
+ FILE_DEVICE_SCANNER = 0x00000019
100
+ FILE_DEVICE_SERIAL_MOUSE_PORT = 0x0000001a
101
+ FILE_DEVICE_SERIAL_PORT = 0x0000001b
102
+ FILE_DEVICE_SCREEN = 0x0000001c
103
+ FILE_DEVICE_SOUND = 0x0000001d
104
+ FILE_DEVICE_STREAMS = 0x0000001e
105
+ FILE_DEVICE_TAPE = 0x0000001f
106
+ FILE_DEVICE_TAPE_FILE_SYSTEM = 0x00000020
107
+ FILE_DEVICE_TRANSPORT = 0x00000021
108
+ FILE_DEVICE_UNKNOWN = 0x00000022
109
+ FILE_DEVICE_VIDEO = 0x00000023
110
+ FILE_DEVICE_VIRTUAL_DISK = 0x00000024
111
+ FILE_DEVICE_WAVE_IN = 0x00000025
112
+ FILE_DEVICE_WAVE_OUT = 0x00000026
113
+ FILE_DEVICE_8042_PORT = 0x00000027
114
+ FILE_DEVICE_NETWORK_REDIRECTOR = 0x00000028
115
+ FILE_DEVICE_BATTERY = 0x00000029
116
+ FILE_DEVICE_BUS_EXTENDER = 0x0000002a
117
+ FILE_DEVICE_MODEM = 0x0000002b
118
+ FILE_DEVICE_VDM = 0x0000002c
119
+ FILE_DEVICE_MASS_STORAGE = 0x0000002d
120
+ FILE_DEVICE_SMB = 0x0000002e
121
+ FILE_DEVICE_KS = 0x0000002f
122
+ FILE_DEVICE_CHANGER = 0x00000030
123
+ FILE_DEVICE_SMARTCARD = 0x00000031
124
+ FILE_DEVICE_ACPI = 0x00000032
125
+ FILE_DEVICE_DVD = 0x00000033
126
+ FILE_DEVICE_FULLSCREEN_VIDEO = 0x00000034
127
+ FILE_DEVICE_DFS_FILE_SYSTEM = 0x00000035
128
+ FILE_DEVICE_DFS_VOLUME = 0x00000036
129
+ FILE_DEVICE_SERENUM = 0x00000037
130
+ FILE_DEVICE_TERMSRV = 0x00000038
131
+ FILE_DEVICE_KSEC = 0x00000039
132
+ FILE_DEVICE_FIPS = 0x0000003A
133
+ FILE_DEVICE_INFINIBAND = 0x0000003B
134
+
135
+ DeviceIoControl = Win32API.new('kernel32', 'DeviceIoControl', 'LLPLPLPP', 'I')
136
+
137
+ def DeviceIoControl(dev, code, in_buf, in_buf_size, out_buf, out_buf_size, bytes, overlapped)
138
+ DeviceIoControl.call(dev, code, in_buf, in_buf_size, out_buf, out_buf_size, bytes, overlapped)
139
+ end
140
+ end
141
+ end