win32-api 1.4.1 → 1.4.2

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 CHANGED
@@ -1,102 +1,107 @@
1
- = 1.4.1 - 29-May-2009
2
- * Callback handling improvements.
3
- * Updated the gemspec description.
4
-
5
- = 1.4.0 - 19-Feb-2009
6
- * Now compatible with Ruby 1.9.x.
7
- * In what will go down as, "It seemed like a good idea at the time", I have
8
- removed the feature where W (wide) character functions were used first if
9
- your $KCODE environment variable was set to "UTF8". It caused too many
10
- headaches in practice, especially amongst Rails users. You must now always
11
- explicitly specify 'W' in the constructor if that's what you want.
12
- * Fixed RF bug #23944 - bad error message for MSVCRT functions that failed
13
- to load properly.
14
-
15
- = 1.3.0 - 1-Jan-2009
16
- * Fixed RubyForge bug #23395, which was caused by inadvertently modifying
17
- a variable within a loop. This caused callbacks to fail in certain
18
- situations.
19
- * Added the Win32::API::LoadLibraryError and Win32::API::PrototypeError classes
20
- to provide more fine grained handling of possible error conditions in the
21
- constructor. These are both subclasses of Win32::API::Error.
22
- * Removed the Win32::API::CallbackError class.
23
- * Changed the upper limit on prototypes from 16 to 20. It turns out that
24
- there are actually Windows functions with more than 16 prototypes.
25
- * Refactored a high iteration test so that it counts as only one test
26
- instead of 1000.
27
-
28
- = 1.2.2 - 27-Nov-2008
29
- * Fixed bug in the error message for illegal prototypes and illegal return
30
- types where the character in question would come out as empty or garbage.
31
- * Passing a bad return type to Win32::API::Callback now raises an error.
32
- * Updated the error message for illegal return types to say, "Illegal return
33
- type" instead of "Illegal prototype" as it did previously.
34
- * The error message for a bad function name passed to Win32::API.new now
35
- matches JRuby's FFI error message.
36
- * Improved the handling of msvcrt functions with regards to skipping 'A'
37
- and 'W' checks. Previously it was checking against the literal string
38
- 'msvcrt'. Now it checks against any string that starts with 'msvcr'.
39
- * Added test-unit 2.x as a prerequisite.
40
- * Added tests for the Win32::API::Callback#address method.
41
- * Added tests to all Win32::API classes that explicitly check error messages.
42
-
43
- = 1.2.1 - 14-Nov-2008
44
- * Fixed and updated callback handling.
45
- * Fixed wide string return handling for pointers and strings.
46
- * Added the Win32::API::Callback#address instance method.
47
- * All errors are now in English instead of your native language, because
48
- that's what Ruby itself does.
49
-
50
- = 1.2.0 - 22-Jul-2008
51
- * Added support for the 'S' (string) prototype and return type. It can be
52
- used instead of 'P' (pointer) for const char*.
53
- * Some internal refactoring. The attempts to load ANSI and/or Wide character
54
- versions of functions are skipped for MSVCRT functions, since they do not
55
- exist. This eliminates some unnecessary LoadLibrary() calls.
56
- * Added a couple of gem building Rake tasks.
57
- * Added a few more tests.
58
-
59
- = 1.1.0 - 12-Jun-2008
60
- * Added the Windows::API::Function class. This is a subclass of Win32::API
61
- meant only for use with raw function pointers.
62
- * Some documentation updates in the source and README files.
63
-
64
- = 1.0.6 - 18-Apr-2008
65
- * Added the effective_function_name method. This allows you to see what the
66
- actual function name is that was defined, e.g. GetUserNameA vs GetUserNameW.
67
- * Replaced an instance of _tcscmp with strcmp. The case in question was always
68
- going to be ASCII.
69
- * Cleaned up some -W3 warnings.
70
- * Added the build_manifest task to the Rakefile, which is automatically run if
71
- you're using a version of Ruby built with VC++ 8 or later. This builds a
72
- ruby.exe.manifest file (if it doesn't already exist).
73
-
74
- = 1.0.5 - 20-Nov-2007
75
- * The API.new method now defaults to "W" (wide character functions) before "A"
76
- (ANSI functions) if the $KCODE global variable is set to 'u' (UTF8).
77
- * Minor improvements to the Rakefile.
78
-
79
- = 1.0.4 - 26-Oct-2007
80
- * Fixed a bug where methods that returned pointers ('P') could choke if the
81
- resulting pointer was 0 or NULL. In this case, nil is now returned instead.
82
- * Tweak to the extconf.rb file that helps the gem build it from source
83
- properly.
84
-
85
- = 1.0.3 - 28-Sep-2007
86
- * Fixed a subtle but dangerous copy-on-write bug in the API#call method.
87
-
88
- = 1.0.2 - 28-Sep-2007
89
- * Fixed a bug in an internal struct member that was causing segfaults. Thanks
90
- go to Lars Olsson for the spot.
91
- * Fixed the 'install' task in the Rakefile. This only affected native builds,
92
- not the prebuilt binary.
93
- * Added a few more tests.
94
-
95
- = 1.0.1 - 27-Sep-2007
96
- * Functions declared with a void prototype no longer require an explicit nil
97
- argument to fulfill the arity requirement. You can still call them with an
98
- explicit nil if you wish, however.
99
- * Fixed the gemspec for the native build.
100
-
101
- = 1.0.0 - 14-Sep-2007
102
- * Initial release
1
+ = 1.4.2 - 31-May-2009
2
+ * Updated the internal StringError() function to better handle the possibility
3
+ of the English .mui file not being found. Thanks go to Michel Demazure for
4
+ the spot.
5
+
6
+ = 1.4.1 - 29-May-2009
7
+ * Callback handling improvements.
8
+ * Updated the gemspec description.
9
+
10
+ = 1.4.0 - 19-Feb-2009
11
+ * Now compatible with Ruby 1.9.x.
12
+ * In what will go down as, "It seemed like a good idea at the time", I have
13
+ removed the feature where W (wide) character functions were used first if
14
+ your $KCODE environment variable was set to "UTF8". It caused too many
15
+ headaches in practice, especially amongst Rails users. You must now always
16
+ explicitly specify 'W' in the constructor if that's what you want.
17
+ * Fixed RF bug #23944 - bad error message for MSVCRT functions that failed
18
+ to load properly.
19
+
20
+ = 1.3.0 - 1-Jan-2009
21
+ * Fixed RubyForge bug #23395, which was caused by inadvertently modifying
22
+ a variable within a loop. This caused callbacks to fail in certain
23
+ situations.
24
+ * Added the Win32::API::LoadLibraryError and Win32::API::PrototypeError classes
25
+ to provide more fine grained handling of possible error conditions in the
26
+ constructor. These are both subclasses of Win32::API::Error.
27
+ * Removed the Win32::API::CallbackError class.
28
+ * Changed the upper limit on prototypes from 16 to 20. It turns out that
29
+ there are actually Windows functions with more than 16 prototypes.
30
+ * Refactored a high iteration test so that it counts as only one test
31
+ instead of 1000.
32
+
33
+ = 1.2.2 - 27-Nov-2008
34
+ * Fixed bug in the error message for illegal prototypes and illegal return
35
+ types where the character in question would come out as empty or garbage.
36
+ * Passing a bad return type to Win32::API::Callback now raises an error.
37
+ * Updated the error message for illegal return types to say, "Illegal return
38
+ type" instead of "Illegal prototype" as it did previously.
39
+ * The error message for a bad function name passed to Win32::API.new now
40
+ matches JRuby's FFI error message.
41
+ * Improved the handling of msvcrt functions with regards to skipping 'A'
42
+ and 'W' checks. Previously it was checking against the literal string
43
+ 'msvcrt'. Now it checks against any string that starts with 'msvcr'.
44
+ * Added test-unit 2.x as a prerequisite.
45
+ * Added tests for the Win32::API::Callback#address method.
46
+ * Added tests to all Win32::API classes that explicitly check error messages.
47
+
48
+ = 1.2.1 - 14-Nov-2008
49
+ * Fixed and updated callback handling.
50
+ * Fixed wide string return handling for pointers and strings.
51
+ * Added the Win32::API::Callback#address instance method.
52
+ * All errors are now in English instead of your native language, because
53
+ that's what Ruby itself does.
54
+
55
+ = 1.2.0 - 22-Jul-2008
56
+ * Added support for the 'S' (string) prototype and return type. It can be
57
+ used instead of 'P' (pointer) for const char*.
58
+ * Some internal refactoring. The attempts to load ANSI and/or Wide character
59
+ versions of functions are skipped for MSVCRT functions, since they do not
60
+ exist. This eliminates some unnecessary LoadLibrary() calls.
61
+ * Added a couple of gem building Rake tasks.
62
+ * Added a few more tests.
63
+
64
+ = 1.1.0 - 12-Jun-2008
65
+ * Added the Windows::API::Function class. This is a subclass of Win32::API
66
+ meant only for use with raw function pointers.
67
+ * Some documentation updates in the source and README files.
68
+
69
+ = 1.0.6 - 18-Apr-2008
70
+ * Added the effective_function_name method. This allows you to see what the
71
+ actual function name is that was defined, e.g. GetUserNameA vs GetUserNameW.
72
+ * Replaced an instance of _tcscmp with strcmp. The case in question was always
73
+ going to be ASCII.
74
+ * Cleaned up some -W3 warnings.
75
+ * Added the build_manifest task to the Rakefile, which is automatically run if
76
+ you're using a version of Ruby built with VC++ 8 or later. This builds a
77
+ ruby.exe.manifest file (if it doesn't already exist).
78
+
79
+ = 1.0.5 - 20-Nov-2007
80
+ * The API.new method now defaults to "W" (wide character functions) before "A"
81
+ (ANSI functions) if the $KCODE global variable is set to 'u' (UTF8).
82
+ * Minor improvements to the Rakefile.
83
+
84
+ = 1.0.4 - 26-Oct-2007
85
+ * Fixed a bug where methods that returned pointers ('P') could choke if the
86
+ resulting pointer was 0 or NULL. In this case, nil is now returned instead.
87
+ * Tweak to the extconf.rb file that helps the gem build it from source
88
+ properly.
89
+
90
+ = 1.0.3 - 28-Sep-2007
91
+ * Fixed a subtle but dangerous copy-on-write bug in the API#call method.
92
+
93
+ = 1.0.2 - 28-Sep-2007
94
+ * Fixed a bug in an internal struct member that was causing segfaults. Thanks
95
+ go to Lars Olsson for the spot.
96
+ * Fixed the 'install' task in the Rakefile. This only affected native builds,
97
+ not the prebuilt binary.
98
+ * Added a few more tests.
99
+
100
+ = 1.0.1 - 27-Sep-2007
101
+ * Functions declared with a void prototype no longer require an explicit nil
102
+ argument to fulfill the arity requirement. You can still call them with an
103
+ explicit nil if you wish, however.
104
+ * Fixed the gemspec for the native build.
105
+
106
+ = 1.0.0 - 14-Sep-2007
107
+ * Initial release
data/MANIFEST CHANGED
@@ -1,10 +1,10 @@
1
- * CHANGES
2
- * MANIFEST
3
- * README
4
- * Rakefile
5
- * win32-api.gemspec
6
- * ext/extconf.rb
7
- * ext/win32/api.c
8
- * test/test_win32_api.rb
9
- * test/test_win32_api_callback.rb
1
+ * CHANGES
2
+ * MANIFEST
3
+ * README
4
+ * Rakefile
5
+ * win32-api.gemspec
6
+ * ext/extconf.rb
7
+ * ext/win32/api.c
8
+ * test/test_win32_api.rb
9
+ * test/test_win32_api_callback.rb
10
10
  * test/test_win32_api_function.rb
data/README CHANGED
@@ -1,103 +1,103 @@
1
- = Description
2
- This is a drop-in replacement for the Win32API library currently part of
3
- Ruby's standard library.
4
-
5
- = Synopsis
6
- require 'win32/api'
7
- include Win32
8
-
9
- # Typical example - Get user name
10
- buf = 0.chr * 260
11
- len = [buf.length].pack('L')
12
-
13
- GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
14
- GetUserName.call(buf, len)
15
-
16
- puts buf.strip
17
-
18
- # Callback example - Enumerate windows
19
- EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
20
- GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
21
- EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
22
- buf = "\0" * 200
23
- GetWindowText.call(handle, buf, 200);
24
- puts buf.strip unless buf.strip.empty?
25
- buf.index(param).nil? ? true : false
26
- }
27
-
28
- EnumWindows.call(EnumWindowsProc, 'UEDIT32')
29
-
30
- # Raw function pointer example - System beep
31
- LoadLibrary = API.new('LoadLibrary', 'P', 'L')
32
- GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
33
-
34
- hlib = LoadLibrary.call('user32')
35
- addr = GetProcAddress.call(hlib, 'MessageBeep')
36
- func = Win32::API::Function.new(addr, 'L', 'L')
37
- func.call(0)
38
-
39
- = Differences between win32-api and Win32API
40
- * This library has callback support
41
- * This library supports raw function pointers.
42
- * This library supports a separate string type for const char* (S).
43
- * Argument order change. The DLL name is now last, not first.
44
- * Removed the 'N' and 'n' prototypes. Always use 'L' for longs now.
45
- * Sensible default arguments for the prototype, return type and DLL name.
46
- * Reader methods for the function name, effective function name, prototype,
47
- return type and DLL.
48
- * Removed the support for lower case prototype and return types. Always
49
- use capital letters.
50
- * Resorts to wide character functions (where possible) when $KCODE is set
51
- to UTF8.
52
-
53
- = Developer's Notes
54
- The current Win32API library that ships with the standard library has been
55
- slated for removal from Ruby 2.0 and it will not receive any updates in the
56
- Ruby 1.8.x branch. I have far too many libraries invested in it to let it
57
- die at this point.
58
-
59
- In addition, the current Win32API library was written in the bad old Ruby
60
- 1.6.x days, which means it doesn't use the newer allocation framework.
61
- There were several other refactorings that I felt it needed to more closely
62
- match how it was actually being used in practice.
63
-
64
- The first order of business was changing the order of the arguments. By
65
- moving the DLL name from first to last, I was able to provide reasonable
66
- default arguments for the prototype, return type and the DLL. Only the
67
- function name is required now.
68
-
69
- There was a laundry list of other refactorings that were needed: sensical
70
- instance variable names with proper accessors, removing support for lower
71
- case prototype and return value characters that no one used in practice,
72
- better naming conventions, the addition of RDoc ready comments and,
73
- especially, callback and raw function pointer support.
74
-
75
- Most importantly, we can now add, modify and fix any features that we feel
76
- best benefit our end users.
77
-
78
- = Documentation
79
- The source file contains inline RDoc documentation. If you installed
80
- this file as a gem, then you have the docs.
81
-
82
- = Warranty
83
- This package is provided "as is" and without any express or
84
- implied warranties, including, without limitation, the implied
85
- warranties of merchantability and fitness for a particular purpose.
86
-
87
- = Known Issues
88
- Possible callback issues when dealing with multi-threaded applications.
89
- We are working on this for the next 1.2.x release.
90
-
91
- Please submit any bug reports to the project page at
92
- http://www.rubyforge.org/projects/win32utils.
93
-
94
- = Copyright
95
- (C) 2003-2009 Daniel J. Berger
96
- All Rights Reserved
97
-
98
- = License
99
- Ruby's
100
-
101
- = Authors
102
- Daniel J. Berger
103
- Park Heesob
1
+ = Description
2
+ This is a drop-in replacement for the Win32API library currently part of
3
+ Ruby's standard library.
4
+
5
+ = Synopsis
6
+ require 'win32/api'
7
+ include Win32
8
+
9
+ # Typical example - Get user name
10
+ buf = 0.chr * 260
11
+ len = [buf.length].pack('L')
12
+
13
+ GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
14
+ GetUserName.call(buf, len)
15
+
16
+ puts buf.strip
17
+
18
+ # Callback example - Enumerate windows
19
+ EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
20
+ GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
21
+ EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
22
+ buf = "\0" * 200
23
+ GetWindowText.call(handle, buf, 200);
24
+ puts buf.strip unless buf.strip.empty?
25
+ buf.index(param).nil? ? true : false
26
+ }
27
+
28
+ EnumWindows.call(EnumWindowsProc, 'UEDIT32')
29
+
30
+ # Raw function pointer example - System beep
31
+ LoadLibrary = API.new('LoadLibrary', 'P', 'L')
32
+ GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
33
+
34
+ hlib = LoadLibrary.call('user32')
35
+ addr = GetProcAddress.call(hlib, 'MessageBeep')
36
+ func = Win32::API::Function.new(addr, 'L', 'L')
37
+ func.call(0)
38
+
39
+ = Differences between win32-api and Win32API
40
+ * This library has callback support
41
+ * This library supports raw function pointers.
42
+ * This library supports a separate string type for const char* (S).
43
+ * Argument order change. The DLL name is now last, not first.
44
+ * Removed the 'N' and 'n' prototypes. Always use 'L' for longs now.
45
+ * Sensible default arguments for the prototype, return type and DLL name.
46
+ * Reader methods for the function name, effective function name, prototype,
47
+ return type and DLL.
48
+ * Removed the support for lower case prototype and return types. Always
49
+ use capital letters.
50
+ * Resorts to wide character functions (where possible) when $KCODE is set
51
+ to UTF8.
52
+
53
+ = Developer's Notes
54
+ The current Win32API library that ships with the standard library has been
55
+ slated for removal from Ruby 2.0 and it will not receive any updates in the
56
+ Ruby 1.8.x branch. I have far too many libraries invested in it to let it
57
+ die at this point.
58
+
59
+ In addition, the current Win32API library was written in the bad old Ruby
60
+ 1.6.x days, which means it doesn't use the newer allocation framework.
61
+ There were several other refactorings that I felt it needed to more closely
62
+ match how it was actually being used in practice.
63
+
64
+ The first order of business was changing the order of the arguments. By
65
+ moving the DLL name from first to last, I was able to provide reasonable
66
+ default arguments for the prototype, return type and the DLL. Only the
67
+ function name is required now.
68
+
69
+ There was a laundry list of other refactorings that were needed: sensical
70
+ instance variable names with proper accessors, removing support for lower
71
+ case prototype and return value characters that no one used in practice,
72
+ better naming conventions, the addition of RDoc ready comments and,
73
+ especially, callback and raw function pointer support.
74
+
75
+ Most importantly, we can now add, modify and fix any features that we feel
76
+ best benefit our end users.
77
+
78
+ = Documentation
79
+ The source file contains inline RDoc documentation. If you installed
80
+ this file as a gem, then you have the docs.
81
+
82
+ = Warranty
83
+ This package is provided "as is" and without any express or
84
+ implied warranties, including, without limitation, the implied
85
+ warranties of merchantability and fitness for a particular purpose.
86
+
87
+ = Known Issues
88
+ Possible callback issues when dealing with multi-threaded applications.
89
+ We are working on this for the next 1.2.x release.
90
+
91
+ Please submit any bug reports to the project page at
92
+ http://www.rubyforge.org/projects/win32utils.
93
+
94
+ = Copyright
95
+ (C) 2003-2009 Daniel J. Berger
96
+ All Rights Reserved
97
+
98
+ = License
99
+ Ruby's
100
+
101
+ = Authors
102
+ Daniel J. Berger
103
+ Park Heesob
data/ext/extconf.rb CHANGED
@@ -1,11 +1,11 @@
1
- ##########################################################################
2
- # extconf.rb
3
- #
4
- # The Windows::API binary should be built using the Rake task, i.e.
5
- # 'rake build' or 'rake install'.
6
- ##########################################################################
7
- require 'mkmf'
8
-
9
- have_func('strncpy_s')
10
-
11
- create_makefile('win32/api', 'win32')
1
+ ##########################################################################
2
+ # extconf.rb
3
+ #
4
+ # The Windows::API binary should be built using the Rake task, i.e.
5
+ # 'rake build' or 'rake install'.
6
+ ##########################################################################
7
+ require 'mkmf'
8
+
9
+ have_func('strncpy_s')
10
+
11
+ create_makefile('win32/api', 'win32')