the example I am playing with is more for me in gaining knowledge in working with windows API'sYou're probably better off getting hold of a compiler (say, the freely available MinGW port of gcc) and using it and Inline::C to access the Windows API's. It's fairly trivial with Inline::C. The following script outputs 0:
use warnings;
use strict;
use Inline C => <<'EOC';
#include <sql.h>
int foo() {
SQLHENV henv = SQL_NULL_HENV;
return SQLAllocHandle(1, 0, &henv);
}
EOC
print foo();
Admittedly that doesn't do anything useful, but at least it returns a sane value and is nowhere near as obtuse as Win32::API.
I must confess that I've spent quite some time trying to get the Win32::API version to return a sane value ... and have failed miserably. Usually, when I can get the Inline::C rendition working, I can then get the Win32::API rendition to work correctly ... sadly, not tonight :-)
I assume it's because I haven't found the correct way to deal with the 3rd argument, but I really don't know.
Update: Nope ... looks like
apl and
Corion have picked up the scent, however.
Update 2:Yep ... I just checked and the SQLRETURN type is a short ... and apparently Win32::API simply fills the other 2 bytes with garbage.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.