cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks. I am trying to use a windoze COM object to do some statistical analysis. The docs (which describe how to do things in C++ or Java, I'm not sure which) say I should create a new instance of the object. I do this like so
$comobj = Win32::OLE->new("STATANPKG\.FDG3");
and the debugger indicates that I've got a valid instance of the object. So far so good. Now I am supposed to initialize the object with a keyphrase. When I try to do it like this
$comobj->Init('the quick brown fox');
It doesn't work (yes, I've insured it's the correct keyphrase). The docs say the method is supposed to be ivoked using the following call
void FDG3::Init(const wchar_t *keyphrase) //throw (Exception)
So I'm wondering if maybe wchar_t specifies some kind of strange windoze string format that does not match a single-quoted string in Perl, and that's why the call isn't working. Does anyone know what this format specifies and how I convert to that?

Many thanks....

Steve

Replies are listed 'Best First'.
Re: Initializing a COM object
by Corion (Patriarch) on Mar 22, 2005 at 19:52 UTC

    Whenever you're trying OLE stuff (COM is different from OLE!), and it doesn't work out via Perl, try it via Excel or WSH (Windows Scripting Host). If you can get it to work in Excel and/or WSH, it's easy to get it to work with Perl afterwards. My guess is that some part of the API is not as you describe it, but you give us neither code nor error message, which makes diagnosis a bit hard.

    As an aside, you don't need to quote the dot:

    my $obj = Win32::OLE->new('STATANPKG.PDG3');