windows-pr 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ = 1.0.9 - 6-Feb-2010
2
+ * A couple of modules that were checking against $KCODE now check against
3
+ __ENCODING__ or the string encoding for Ruby 1.9.x.
4
+ * Removed an indentation warning that was revealed by Ruby 1.9.x.
5
+ * Refactored the Rakefile, scoping and adding additional tasks.
6
+ * Updated some tests to handling Ruby 1.9.x better. All tests now pass
7
+ without warning with 1.9.x.
8
+ * Added SERVICE_ACCEPT_PRESHUTDOWN constant to service.rb.
9
+
1
10
  = 1.0.8 - 24-Aug-2009
2
11
  * Several return value constants that were set at -1 are now set to
3
12
  0xFFFFFFFF instead because win32-api returns unsigned longs.
data/README CHANGED
@@ -1,153 +1,149 @@
1
- = windows-pr
2
1
  == Description
3
- A collection of Windows functions predefined for you via Win32::API.
4
- Hence the 'pr', for 'Pure Ruby'.
2
+ A collection of Windows functions predefined for you via Win32::API.
3
+ Hence the 'pr', for 'Pure Ruby'.
5
4
 
6
5
  == Synopsis
7
- require 'windows/path'
8
-
9
- class Foo
10
- include Windows::Path
11
-
12
- if PathIsRoot.call("C:\\") > 0
13
- ...
14
- end
6
+ require 'windows/path'
7
+
8
+ class Foo
9
+ include Windows::Path
10
+
11
+ if PathIsRoot.call("C:\\") > 0
12
+ ...
13
+ end
15
14
 
16
- # or
17
-
18
- if PathIsRoot("C:\\")
19
- ...
20
- end
21
- end
15
+ # or
16
+
17
+ if PathIsRoot("C:\\")
18
+ ...
19
+ end
20
+ end
22
21
 
23
22
  == Installation
24
- === Gem Installation
25
- gem install windows-pr
26
- === Manual Installation
27
- rake install
23
+ gem install windows-pr
28
24
 
29
25
  == Methods
30
- Each of the various files included as part of this package provide a series
31
- of constants corresponding to the equivalent Windows API function and
32
- related numeric constants. For example, if you require 'windows/path',
33
- you now have PathIsRoot, PathIsUNC, etc, available to you as Win32::API
34
- objects in the form of constants.
35
-
36
- A wrapper has been provided for each method in order to avoid the
37
- Win32::API#call method. So, instead of PathIsRoot.call(path) you can
38
- invoke it as PathIsRoot(path). If the original function is lower case
39
- then the wrapper method is lower case as well. For example, instead of
40
- doing 'Memcpy.call(dest, src, size)' you can do 'memcpy(dest, src, size)'.
41
-
42
- Remember boys and girls, if you write 'PathIsRoot', you're referring to
43
- the constant. If you write 'PathIsRoot()', you're calling the wrapper
44
- method.
45
-
46
- Boolean methods automatically perform a check for success or failure. So,
47
- instead of having to do something like 'if PathIsRoot(path) > 0' you can
48
- just do 'if PathIsRoot(path)'. However, I do not add this nicety for the
49
- MSVCRT functions that return int's because some functions have multiple
50
- return values which you may want to inspect. So, rather than making you
51
- guess, I have simply declared that you must inspect return values manually
52
- for any MSVCRT module.
53
-
54
- Source files contain related functions, by topic. For example, the
55
- clipboard.rb file contains clipboard related functions, such as
56
- CloseClipboard(), as well as constants such as CF_TEXT, CF_BITMAP, etc.
26
+ Each of the various files included as part of this package provide a series
27
+ of constants corresponding to the equivalent Windows API function and
28
+ related numeric constants. For example, if you require 'windows/path',
29
+ you now have PathIsRoot, PathIsUNC, etc, available to you as Win32::API
30
+ objects in the form of constants.
31
+
32
+ A wrapper has been provided for each method in order to avoid the
33
+ Win32::API#call method. So, instead of PathIsRoot.call(path) you can
34
+ invoke it as PathIsRoot(path). If the original function is lower case
35
+ then the wrapper method is lower case as well. For example, instead of
36
+ doing 'Memcpy.call(dest, src, size)' you can do 'memcpy(dest, src, size)'.
37
+
38
+ Remember boys and girls, if you write 'PathIsRoot', you're referring to
39
+ the constant. If you write 'PathIsRoot()', you're calling the wrapper
40
+ method.
41
+
42
+ Boolean methods automatically perform a check for success or failure. So,
43
+ instead of having to do something like 'if PathIsRoot(path) > 0' you can
44
+ just do 'if PathIsRoot(path)'. However, I do not add this nicety for the
45
+ MSVCRT functions that return int's because some functions have multiple
46
+ return values which you may want to inspect. So, rather than making you
47
+ guess, I have simply declared that you must inspect return values manually
48
+ for any MSVCRT module.
49
+
50
+ Source files contain related functions, by topic. For example, the
51
+ clipboard.rb file contains clipboard related functions, such as
52
+ CloseClipboard(), as well as constants such as CF_TEXT, CF_BITMAP, etc.
57
53
 
58
54
  == Wide character functions
59
- I decided that the $KCODE handling was a bad idea, so most of the $KCODE
60
- handling has been removed. The only methods that change their behavior
61
- based on $KCODE are the multi_to_wide and wide_to_multi helper methods
62
- in the Windows::Unicode module. If $KCODE is set to UTF8, then the code
63
- point used is CP_UTF8. Otherwise, CP_ACP is used.
64
-
65
- The modules all come with explicit ANSI and Wide (Unicode) functions,
66
- when available from MS Windows. By default, a function without an explicit
67
- 'A' at the end of the function name uses the ANSI version. It is up to you
68
- to use the wide ('W') functions explicitly if you wish.
69
-
55
+ I decided that the $KCODE handling was a bad idea, so most of the $KCODE
56
+ handling has been removed. The only methods that change their behavior
57
+ based on $KCODE are the multi_to_wide and wide_to_multi helper methods
58
+ in the Windows::Unicode module. If $KCODE is set to UTF8, then the code
59
+ point used is CP_UTF8. Otherwise, CP_ACP is used.
60
+
61
+ The modules all come with explicit ANSI and Wide (Unicode) functions,
62
+ when available from MS Windows. By default, a function without an explicit
63
+ 'A' at the end of the function name uses the ANSI version. It is up to you
64
+ to use the wide ('W') functions explicitly if you wish.
65
+
70
66
  == Platform specific functions
71
- Not all functions are defined on all platforms. For example, the
67
+ Not all functions are defined on all platforms. For example, the
72
68
  AttachConsole() function is only defined on Windows XP and later. If you
73
- need to conditionally test for its existence, simply use the 'defined?'
74
- method:
69
+ eed to conditionally test for its existence, simply use the 'defined?'
70
+ method:
75
71
 
76
- if defined? AttachConsole
77
- # Do something
78
- else
79
- # Do something else
80
- end
72
+ if defined? AttachConsole
73
+ # Do something
74
+ else
75
+ # Do something else
76
+ end
81
77
 
82
78
  == Where are the tests, dude?
83
- While I've made some effort to test these functions, there are simply too
84
- many for me to effectively test them all. We're ultimately talking about
85
- hundreds, if not thousands, of functions, and I don't know what all of them
86
- actually do. That being said, I will add tests where and when I can.
87
-
88
- If you find that I've declared the function prototype wrong for a given
89
- function, please let me know ASAP and I'll fix it. An example program
90
- demonstrating the problem would be helpful, too. Or, if you'd just like
91
- to contribute some test cases, that's fine as well.
79
+ While I've made some effort to test these functions, there are simply too
80
+ many for me to effectively test them all. We're ultimately talking about
81
+ hundreds, if not thousands, of functions, and I don't know what all of them
82
+ actually do. That being said, I will add tests where and when I can.
83
+
84
+ If you find that I've declared the function prototype wrong for a given
85
+ function, please let me know ASAP and I'll fix it. An example program
86
+ demonstrating the problem would be helpful, too. Or, if you'd just like
87
+ to contribute some test cases, that's fine as well.
92
88
 
93
89
  == What's the point?
94
- I became tired of redefining Windows functions over and over whenever I
95
- wanted to use the Win32API library. I thought it would be very handy to
96
- have them predefined for me in a library with convenient wrapper methods
97
- to boot.
98
-
99
- While it's true that Moonwolf has a library on the RAA that includes many
100
- of these functions defined already, there are a few issues with it. First,
101
- it puts *every* function and constant in one or two files. That's a waste
102
- of memory, hard to organize & maintain, and impossible to test. Second,
103
- some of his function declarations are wrong. Third, some of the functions
104
- I needed for my own projects are missing. Fourth, there's no gem. Lastly,
105
- I haven't seen an update in over 6 years, which leads me to believe it is
106
- no longer maintained.
90
+ I became tired of redefining Windows functions over and over whenever I
91
+ wanted to use the Win32API library. I thought it would be very handy to
92
+ have them predefined for me in a library with convenient wrapper methods
93
+ to boot.
94
+
95
+ While it's true that Moonwolf has a library on the RAA that includes many
96
+ of these functions defined already, there are a few issues with it. First,
97
+ it puts *every* function and constant in one or two files. That's a waste
98
+ of memory, hard to organize & maintain, and impossible to test. Second,
99
+ some of his function declarations are wrong. Third, some of the functions
100
+ I needed for my own projects are missing. Fourth, there's no gem. Lastly,
101
+ I haven't seen an update in over 6 years, which leads me to believe it is
102
+ no longer maintained.
107
103
 
108
104
  == Hey, I'm missing function X!
109
- I have only defined a small subset of the overall Windows API. It would
110
- take me years to define them *all*. I defined the ones I needed first,
111
- plus some that I thought would be useful to others. I will continue to
112
- add functions in my spare time, or (especially) by request.
105
+ I have only defined a small subset of the overall Windows API. It would
106
+ take me years to define them *all*. I defined the ones I needed first,
107
+ plus some that I thought would be useful to others. I will continue to
108
+ add functions in my spare time, or (especially) by request.
113
109
 
114
110
  == Bugs
115
- None that I'm aware of. Please report any bugs on the project page at
116
- http://www.rubyforge.org/projects/win32utils.
111
+ None that I'm aware of. Please report any bugs on the project page at
112
+ http://www.rubyforge.org/projects/win32utils.
117
113
 
118
- The only real bugs you could find are either bad prototype declarations
119
- or bad constant values. Sometimes I forget to wrap functions properly
120
- that may not be defined on older Windows platforms. But, please report
121
- any of these issues on the project page should you stumble into them.
114
+ The only real bugs you could find are either bad prototype declarations
115
+ or bad constant values. Sometimes I forget to wrap functions properly
116
+ that may not be defined on older Windows platforms. But, please report
117
+ any of these issues on the project page should you stumble into them.
122
118
 
123
119
  == Known Issues
124
- In some cases the MSDN docs are wrong, and we have to learn it the hard
125
- way. If you should happen to find a documentation bug on their site,
126
- please contact them and let them know. They're generally good about fixing
127
- them.
120
+ In some cases the MSDN docs are wrong, and we have to learn it the hard
121
+ way. If you should happen to find a documentation bug on their site,
122
+ please contact them and let them know. They're generally good about fixing
123
+ them.
128
124
 
129
- In other cases library functions are not exported by the dll. For example,
130
- my version of shlwapi.dll does not export the PathIsHTMLFile() function,
131
- despite being well past the minimum version for that DLL. There is nothing
132
- you or I can do about it short of rebuilding the DLL file from scratch
133
- and/or reporting the issue to Microsoft.
125
+ In other cases library functions are not exported by the dll. For example,
126
+ my version of shlwapi.dll does not export the PathIsHTMLFile() function,
127
+ despite being well past the minimum version for that DLL. There is nothing
128
+ you or I can do about it short of rebuilding the DLL file from scratch
129
+ and/or reporting the issue to Microsoft.
134
130
 
135
131
  == Supported Platforms
136
- I only support the Windows NT family of Windows, and then only Windows
137
- 2000 and later.
132
+ I only support the Windows NT family of Windows, and then only Windows
133
+ 2000 and later.
138
134
 
139
135
  == License
140
- Artistic 2.0
136
+ Artistic 2.0
141
137
 
142
138
  == Warranty
143
- This package is provided "as is" and without any express or
144
- implied warranties, including, without limitation, the implied
145
- warranties of merchantability and fitness for a particular purpose.
139
+ This package is provided "as is" and without any express or
140
+ implied warranties, including, without limitation, the implied
141
+ warranties of merchantability and fitness for a particular purpose.
146
142
 
147
143
  == Copyright
148
- (C) 2006-2009, Daniel J. Berger
149
- All Rights Reserved
144
+ (C) 2006-2010, Daniel J. Berger
145
+ All Rights Reserved
150
146
 
151
147
  == Author(s)
152
- Daniel Berger
153
- Park Heesob
148
+ Daniel Berger
149
+ Park Heesob
data/Rakefile CHANGED
@@ -3,68 +3,83 @@ require 'rake/testtask'
3
3
  require 'rbconfig'
4
4
  include Config
5
5
 
6
- desc "Install the windows-pr package (non-gem)"
6
+ desc "Install the windows-pr library (non-gem)"
7
7
  task :install do
8
- sitelibdir = CONFIG["sitelibdir"]
9
- installdir = File.join(sitelibdir, 'windows')
10
- installdir_msvcrt = File.join(installdir, 'msvcrt')
11
- installdir_gdi = File.join(installdir, 'gdi')
12
- installdir_com = File.join(installdir, 'com')
13
- installdir_network = File.join(installdir, 'network')
14
- installdir_window = File.join(installdir, 'window')
15
- installdir_ntfs = File.join(installdir, 'ntfs')
8
+ sitelibdir = CONFIG["sitelibdir"]
9
+ installdir = File.join(sitelibdir, 'windows')
10
+ installdir_msvcrt = File.join(installdir, 'msvcrt')
11
+ installdir_gdi = File.join(installdir, 'gdi')
12
+ installdir_com = File.join(installdir, 'com')
13
+ installdir_network = File.join(installdir, 'network')
14
+ installdir_window = File.join(installdir, 'window')
15
+ installdir_ntfs = File.join(installdir, 'ntfs')
16
16
 
17
- FileUtils.mkdir_p(installdir)
18
- FileUtils.mkdir_p(installdir_msvcrt)
19
- FileUtils.mkdir_p(installdir_gdi)
20
- FileUtils.mkdir_p(installdir_com)
21
- FileUtils.mkdir_p(installdir_network)
22
- FileUtils.mkdir_p(installdir_window)
23
- FileUtils.mkdir_p(installdir_ntfs)
17
+ FileUtils.mkdir_p(installdir)
18
+ FileUtils.mkdir_p(installdir_msvcrt)
19
+ FileUtils.mkdir_p(installdir_gdi)
20
+ FileUtils.mkdir_p(installdir_com)
21
+ FileUtils.mkdir_p(installdir_network)
22
+ FileUtils.mkdir_p(installdir_window)
23
+ FileUtils.mkdir_p(installdir_ntfs)
24
24
 
25
- Dir["lib/windows/*.rb"].each{ |file|
26
- FileUtils.cp(file, installdir, :verbose => true)
27
- }
25
+ Dir["lib/windows/*.rb"].each{ |file|
26
+ FileUtils.cp(file, installdir, :verbose => true)
27
+ }
28
28
 
29
- Dir["lib/windows/msvcrt/*.rb"].each{ |file|
30
- FileUtils.cp(file, installdir_msvcrt, :verbose => true)
31
- }
29
+ Dir["lib/windows/msvcrt/*.rb"].each{ |file|
30
+ FileUtils.cp(file, installdir_msvcrt, :verbose => true)
31
+ }
32
32
 
33
- Dir["lib/windows/gdi/*.rb"].each{ |file|
34
- FileUtils.cp(file, installdir_gdi, :verbose => true)
35
- }
33
+ Dir["lib/windows/gdi/*.rb"].each{ |file|
34
+ FileUtils.cp(file, installdir_gdi, :verbose => true)
35
+ }
36
36
 
37
- Dir["lib/windows/com/*.rb"].each{ |file|
38
- FileUtils.cp(file, installdir_com, :verbose => true)
39
- }
37
+ Dir["lib/windows/com/*.rb"].each{ |file|
38
+ FileUtils.cp(file, installdir_com, :verbose => true)
39
+ }
40
40
 
41
- Dir["lib/windows/network/*.rb"].each{ |file|
42
- FileUtils.cp(file, installdir_network, :verbose => true)
43
- }
41
+ Dir["lib/windows/network/*.rb"].each{ |file|
42
+ FileUtils.cp(file, installdir_network, :verbose => true)
43
+ }
44
44
 
45
- Dir["lib/windows/window/*.rb"].each{ |file|
46
- FileUtils.cp(file, installdir_window, :verbose => true)
47
- }
45
+ Dir["lib/windows/window/*.rb"].each{ |file|
46
+ FileUtils.cp(file, installdir_window, :verbose => true)
47
+ }
48
48
 
49
- Dir["lib/windows/ntfs/*.rb"].each{ |file|
50
- FileUtils.cp(file, installdir_ntfs, :verbose => true)
51
- }
49
+ Dir["lib/windows/ntfs/*.rb"].each{ |file|
50
+ FileUtils.cp(file, installdir_ntfs, :verbose => true)
51
+ }
52
52
  end
53
53
 
54
- desc "Install the windows-pr package as a gem"
55
- task :install_gem do
56
- ruby 'windows-pr.gemspec'
57
- file = Dir["*.gem"].first
58
- sh "gem install #{file}"
59
- end
54
+ namespace 'gem' do
55
+ desc 'Build the windows-pr gem'
56
+ task :build do
57
+ spec = eval(IO.read('windows-pr.gemspec'))
58
+ Gem::Builder.new(spec).build
59
+ end
60
60
 
61
- Rake::TestTask.new do |t|
62
- t.warning = true
63
- t.test_files = FileList['test/tc*']
61
+ desc 'Install the windows-pr gem'
62
+ task :install => [:build] do
63
+ file = Dir["*.gem"].first
64
+ sh "gem install #{file}"
65
+ end
64
66
  end
65
67
 
66
- Rake::TestTask.new('test-clipboard') do |t|
67
- t.warning = true
68
- t.verbose = true
69
- t.test_files = FileList['test/tc_clipboard.rb']
68
+ namespace 'test' do
69
+ Rake::TestTask.new('all') do |t|
70
+ t.warning = true
71
+ t.test_files = FileList['test/tc*']
72
+ end
73
+
74
+ Rake::TestTask.new('clipboard') do |t|
75
+ t.warning = true
76
+ t.verbose = true
77
+ t.test_files = FileList['test/tc_clipboard.rb']
78
+ end
79
+
80
+ Rake::TestTask.new('unicode') do |t|
81
+ t.warning = true
82
+ t.verbose = true
83
+ t.test_files = FileList['test/tc_unicode.rb']
84
+ end
70
85
  end
@@ -1,14 +1,14 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module COM
5
- module Accessibility
6
- API.auto_namespace = 'Windows::COM::Accessibility'
7
- API.auto_constant = true
8
- API.auto_method = true
9
- API.auto_unicode = false
10
-
11
- API.new('ObjectFromLresult', 'LPIP', 'L', 'oleacc')
12
- end
13
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module COM
5
+ module Accessibility
6
+ API.auto_namespace = 'Windows::COM::Accessibility'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = false
10
+
11
+ API.new('ObjectFromLresult', 'LPIP', 'L', 'oleacc')
12
+ end
13
+ end
14
14
  end
@@ -1,23 +1,31 @@
1
1
  module Windows
2
- module Limits
3
- MINCHAR = 0x80
4
- MAXCHAR = 0x7f
5
- MINSHORT = 0x8000
6
- MAXSHORT = 0x7fff
7
- MINLONG = 0x80000000
8
- MAXLONG = 0x7fffffff
9
- MAXBYTE = 0xff
10
- MAXWORD = 0xffff
11
- MAXDWORD = 0xffffffff
2
+ module Limits
3
+ MINCHAR = 0x80
4
+ MAXCHAR = 0x7f
5
+ MINSHORT = 0x8000
6
+ MAXSHORT = 0x7fff
7
+ MINLONG = 0x80000000
8
+ MAXLONG = 0x7fffffff
9
+ MAXBYTE = 0xff
10
+ MAXWORD = 0xffff
11
+ MAXDWORD = 0xffffffff
12
12
 
13
- # For wide character functions the actual path limit is actually 32k
14
- # for most functions that deal with paths, but in the interests of not
15
- # wasting huge chunks of memory on buffers I limit it to 1k, which
16
- # should be more than enough in practice.
13
+ # For wide character functions the actual path limit is actually 32k
14
+ # for most functions that deal with paths, but in the interests of not
15
+ # wasting huge chunks of memory on buffers I limit it to 1k, which
16
+ # should be more than enough in practice.
17
+ if RUBY_VERSION.to_f >= 1.9
18
+ if __ENCODING__.name == 'UTF-8'
19
+ MAXPATH = 1024
20
+ else
21
+ MAXPATH = 256
22
+ end
23
+ else
17
24
  if $KCODE == 'UTF8'
18
- MAXPATH = 1024
25
+ MAXPATH = 1024
19
26
  else
20
- MAXPATH = 256
27
+ MAXPATH = 256
21
28
  end
22
- end
23
- end
29
+ end
30
+ end
31
+ end