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