Berger, Daniel
2007-Nov-13 21:11 UTC
[Win32utils-devel] win32-api idea - wide method first based on $KCODE
All, Currently, the Win32::API.new method will search for the function name, then the ''A'' (ANSI) name, and finally the ''W'' (Wide) name. The code looks something like this: fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_proc)->ptr)); if(!fProc){ VALUE v_ascii = rb_str_new3(v_proc); v_ascii = rb_str_cat(v_ascii, "A", 1); fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_ascii)->ptr)); if(!fProc){ VALUE v_unicode = rb_str_new3(v_proc); v_unicode = rb_str_cat(v_unicode, "W", 1); fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_unicode)->ptr)); ... So, for example, when you do this: Win32::API.new(''SomeFunc'',...) It looks for SomeFunc. If that fails it looks for SomeFuncA (which is what most of the functions actually default to). If that fails it looks for SomeFuncW. If that fails, then an error is raised. What about switching the order so that it looks for SomeFuncW -first- and SomeFuncA -second- if $KCODE = u? Does that seem reasonable? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.
Wayne Vucenic
2007-Nov-14 01:45 UTC
[Win32utils-devel] win32-api idea - wide method first based on $KCODE
Hi Dan, I''m hardly an expert on any of this, but what you propose makes sense to me. Best regards, Wayne On Nov 13, 2007 1:11 PM, Berger, Daniel <Daniel.Berger at qwest.com> wrote:> All, > > Currently, the Win32::API.new method will search for the function name, > then the ''A'' (ANSI) name, and finally the ''W'' (Wide) name. The code > looks something like this: > > fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_proc)->ptr)); > > if(!fProc){ > VALUE v_ascii = rb_str_new3(v_proc); > v_ascii = rb_str_cat(v_ascii, "A", 1); > fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_ascii)->ptr)); > > if(!fProc){ > VALUE v_unicode = rb_str_new3(v_proc); > v_unicode = rb_str_cat(v_unicode, "W", 1); > fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_unicode)->ptr)); > ... > > So, for example, when you do this: > > Win32::API.new(''SomeFunc'',...) > > It looks for SomeFunc. If that fails it looks for SomeFuncA (which is > what most of the functions actually default to). If that fails it looks > for SomeFuncW. If that fails, then an error is raised. > > What about switching the order so that it looks for SomeFuncW -first- > and SomeFuncA -second- if $KCODE = u? Does that seem reasonable? > > Regards, > > Dan > > > > This communication is the property of Qwest and may contain confidential > or > privileged information. Unauthorized use of this communication is strictly > prohibited and may be unlawful. If you have received this communication > in error, please immediately notify the sender by reply e-mail and destroy > all copies of the communication and any attachments. > _______________________________________________ > win32utils-devel mailing list > win32utils-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/win32utils-devel >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/win32utils-devel/attachments/20071113/694d840a/attachment.html