http://msdn.microsoft.com/en-us/library/windows/desktop/ms221069%28v=vs.85%29.aspx
A BSTR * is something similar to a char **, but it is NOT a char ** or WCHAR **. If the function wants to realloc, free, or take ownership of the BSTR, it can typically do so by put a NULL in your BSTR * or putting a different BSTR into the BSTR *. I am guessing since you didn't provide any docs on the C function it can take ownership. Win32::OLE has a couple nice looking C SV to BSTR and BSTR to SV functions but they are not exported from the DLL by default. A BSTR comes from a foreign memory allocation, you can't treat a BSTR as a regular string-ish scalar (I am not going to write an overload.pm module that implements BSTRs, sorry). You will probably have to treat it as an integer in Perl, then use Perl XS subs or pack() to read, write, and free it. I don't see anything very difficult here, it is just going to take more code in Perl to do it than in C. Windows OS has way too many memory allocators and string formats. Soon someone will want to use ASCII_STRING and UNICODE_STRING with Win32::API.
TLDR: If your BSTR didn't come from SysAllocString or the like, you will probably crash.
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.