win32-api 1.0.4-x86-mswin32-60 → 1.0.5-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -1
- data/README +13 -0
- data/ext/extconf.rb +10 -0
- data/ext/win32/api.c +14 -6
- data/lib/win32/api.so +0 -0
- data/test/tc_win32_api.rb +1 -1
- metadata +43 -46
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 1.0.5 - 20-Nov-2007
|
2
|
+
* The API.new method now defaults to "W" (wide character functions) before "A"
|
3
|
+
(ANSI functions) if the $KCODE global variable is set to 'u' (UTF8).
|
4
|
+
* Minor improvements to the Rakefile.
|
5
|
+
|
1
6
|
= 1.0.4 - 26-Oct-2007
|
2
7
|
* Fixed a bug where methods that returned pointers ('P') could choke if the
|
3
8
|
resulting pointer was 0 or NULL. In this case, nil is now returned instead.
|
@@ -21,4 +26,4 @@
|
|
21
26
|
* Fixed the gemspec for the native build.
|
22
27
|
|
23
28
|
= 1.0.0 - 14-Sep-2007
|
24
|
-
* Initial release
|
29
|
+
* Initial release
|
data/README
CHANGED
@@ -14,13 +14,26 @@
|
|
14
14
|
|
15
15
|
puts buf.strip
|
16
16
|
|
17
|
+
# Callback example
|
18
|
+
EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
|
19
|
+
GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
|
20
|
+
EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
|
21
|
+
buf = "\0" * 200
|
22
|
+
GetWindowText.call(handle, buf, 200);
|
23
|
+
puts buf.strip
|
24
|
+
buf.index(param).nil? ? true : false
|
25
|
+
}
|
26
|
+
|
17
27
|
= Differences between win32-api and Win32API
|
28
|
+
* This library has callback support!
|
18
29
|
* Argument order change. The DLL name is now last, not first.
|
19
30
|
* Removed the 'N' and 'n'. Always use 'L' for longs now.
|
20
31
|
* Sensible default arguments for the prototype, return type and DLL name.
|
21
32
|
* Reader methods for the function name, prototype, return type and DLL.
|
22
33
|
* Removed the support for lower case prototype and return types. Always
|
23
34
|
use capital letters.
|
35
|
+
* Resorts to wide character functions (where possible) when $KCODE is set
|
36
|
+
to UTF8.
|
24
37
|
|
25
38
|
= Developer's Notes
|
26
39
|
The current Win32API library that ships with the standard library has been
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,10 @@
|
|
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
|
+
create_makefile('win32/api', 'win32')
|
data/ext/win32/api.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#include <windows.h>
|
3
3
|
|
4
4
|
#define MAX_BUF 1024
|
5
|
-
#define WINDOWS_API_VERSION "1.0.
|
5
|
+
#define WINDOWS_API_VERSION "1.0.5"
|
6
6
|
|
7
7
|
#define _T_VOID 0
|
8
8
|
#define _T_LONG 1
|
@@ -146,6 +146,8 @@ static VALUE api_init(int argc, VALUE* argv, VALUE self)
|
|
146
146
|
FARPROC fProc;
|
147
147
|
Win32API* ptr;
|
148
148
|
int i;
|
149
|
+
char* first = "A";
|
150
|
+
char* second = "W";
|
149
151
|
VALUE v_proc, v_proto, v_return, v_dll, v_bool, v_name;
|
150
152
|
|
151
153
|
rb_scan_args(argc, argv, "13", &v_proc, &v_proto, &v_return, &v_dll);
|
@@ -190,19 +192,25 @@ static VALUE api_init(int argc, VALUE* argv, VALUE self)
|
|
190
192
|
ptr->library = hLibrary;
|
191
193
|
|
192
194
|
/* Attempt to get the function. If it fails, try again with an 'A'
|
193
|
-
* appended. If that fails, try again with a 'W' appended.
|
195
|
+
* appended. If that fails, try again with a 'W' appended. If that
|
194
196
|
* still fails, raise an API::Error.
|
195
197
|
*/
|
196
198
|
fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_proc)->ptr));
|
197
199
|
|
200
|
+
/* The order of 'A' and 'W' is reversed if $KCODE is set to 'UTF8'. */
|
201
|
+
if(!_tcscmp(rb_get_kcode(), "UTF8")){
|
202
|
+
first = "W";
|
203
|
+
second = "A";
|
204
|
+
}
|
205
|
+
|
198
206
|
if(!fProc){
|
199
207
|
VALUE v_ascii = rb_str_new3(v_proc);
|
200
|
-
v_ascii = rb_str_cat(v_ascii,
|
208
|
+
v_ascii = rb_str_cat(v_ascii, first, 1);
|
201
209
|
fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_ascii)->ptr));
|
202
210
|
|
203
211
|
if(!fProc){
|
204
212
|
VALUE v_unicode = rb_str_new3(v_proc);
|
205
|
-
v_unicode = rb_str_cat(v_unicode,
|
213
|
+
v_unicode = rb_str_cat(v_unicode, second, 1);
|
206
214
|
fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_unicode)->ptr));
|
207
215
|
|
208
216
|
if(!fProc){
|
@@ -342,7 +350,7 @@ DWORD CallbackFunction(PARAM param)
|
|
342
350
|
if(NIL_P(v_retval)){
|
343
351
|
return 0;
|
344
352
|
}
|
345
|
-
else if
|
353
|
+
else if(FIXNUM_P(v_retval)){
|
346
354
|
return NUM2ULONG(v_retval);
|
347
355
|
}
|
348
356
|
else{
|
@@ -519,6 +527,6 @@ void Init_api(){
|
|
519
527
|
|
520
528
|
/* Constants */
|
521
529
|
|
522
|
-
/* 1.
|
530
|
+
/* 1.1.0: The version of this library, returned as a String */
|
523
531
|
rb_define_const(cAPI, "VERSION", rb_str_new2(WINDOWS_API_VERSION));
|
524
532
|
}
|
data/lib/win32/api.so
CHANGED
Binary file
|
data/test/tc_win32_api.rb
CHANGED
metadata
CHANGED
@@ -1,21 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4.6
|
3
|
-
specification_version: 2
|
4
2
|
name: win32-api
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/win32utils
|
13
|
-
rubyforge_project: win32utils
|
14
|
-
description: A superior replacement for Win32API
|
4
|
+
version: 1.0.5
|
5
|
+
platform: x86-mswin32-60
|
6
|
+
authors:
|
7
|
+
- Daniel J. Berger
|
15
8
|
autorequire:
|
16
|
-
default_executable:
|
17
9
|
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-01 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A superior replacement for Win32API
|
17
|
+
email: djberg96@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- CHANGES
|
25
|
+
- MANIFEST
|
26
|
+
- ext/win32/api.c
|
27
|
+
files:
|
28
|
+
- ext/extconf.rb
|
29
|
+
- ext/win32
|
30
|
+
- ext/win32/api.c
|
31
|
+
- test/tc_win32_api.rb
|
32
|
+
- test/tc_win32_api_callback.rb
|
33
|
+
- lib/win32/api.so
|
34
|
+
- README
|
35
|
+
- CHANGES
|
36
|
+
- MANIFEST
|
18
37
|
has_rdoc: true
|
38
|
+
homepage: http://www.rubyforge.org/projects/win32utils
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
19
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
20
45
|
requirements:
|
21
46
|
- - ">="
|
@@ -28,41 +53,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
28
53
|
- !ruby/object:Gem::Version
|
29
54
|
version: "0"
|
30
55
|
version:
|
31
|
-
|
32
|
-
cpu: x86
|
33
|
-
os: mswin32
|
34
|
-
version: "60"
|
35
|
-
signing_key:
|
36
|
-
cert_chain: []
|
56
|
+
requirements: []
|
37
57
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- ext/win32/api.c
|
44
|
-
- lib/win32
|
45
|
-
- lib/win32/api.so
|
46
|
-
- test/tc_win32_api.rb
|
47
|
-
- test/tc_win32_api_callback.rb
|
48
|
-
- README
|
49
|
-
- CHANGES
|
50
|
-
- MANIFEST
|
58
|
+
rubyforge_project: win32utils
|
59
|
+
rubygems_version: 1.0.1
|
60
|
+
signing_key:
|
61
|
+
specification_version: 2
|
62
|
+
summary: A superior replacement for Win32API
|
51
63
|
test_files:
|
52
64
|
- test/tc_win32_api.rb
|
53
65
|
- test/tc_win32_api_callback.rb
|
54
|
-
rdoc_options: []
|
55
|
-
|
56
|
-
extra_rdoc_files:
|
57
|
-
- README
|
58
|
-
- CHANGES
|
59
|
-
- MANIFEST
|
60
|
-
- ext/win32/api.c
|
61
|
-
executables: []
|
62
|
-
|
63
|
-
extensions: []
|
64
|
-
|
65
|
-
requirements: []
|
66
|
-
|
67
|
-
dependencies: []
|
68
|
-
|