Every now and then I find a need to call a function that would be second nature if I were using Visual C++ in a Windows environment. I happened across Win32::API, and was very pleasantly surprised at what the module can do.
Win32::API allows functions to be imported from Windows DLL files. It also makes the job much easier by making the actual calling of the function incredibly simple. No more trying to do weird type conversions and stupid pointer tricks - just pack
your variables and call the function. If the function doesn't take a structure as a parameter, it's even easier - just call it like a normal Perl sub.
I've had great success at using it, and while I haven't benchmarked any results it appears to be quite fast. Coding the function call is simple, also. It takes longer to research the function and its parameters than it does to write the call.
Drawbacks: There are two drawbacks to Win32::API that I've noticed so far. One could be easily remedied, while the other is probably not something I should hold my breath for. Here they are:
- It would be nice if the documentation listed or gave a link to information about what size standard MS parameters are. It's kind of a pain to have to track down what the difference between a WORD and a DWORD is so you know what to pack
- It would be really nice if support for functions that have callbacks. One example I'm thinking of is placing icons in the system tray. To be able to respond to mouse clicks, the function call that places the icon there must specify a callback that gets executed on a mouse click. AFAIK, there is no way to do this yet in Perl, and it may be impossible at the present.
Win32::API is a great way to build a Windows based Perl solution without having to resort to an MS programming solution because "there's no module that does X".
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||