J, I just reviewed the notes I used to teach COM from. I'm feeling more certain that if you want to pass arrays with the dispatch interface, you can either pass a variant or pass a SAFEARRAY. You appear to be doing neither in your C++ code. Sieg
-----Original Message----- From: J aperlh [mailto:[EMAIL PROTECTED] Sent: Friday, June 03, 2005 12:05 AM To: Siegfried Heintze Cc: beginners@perl.org Subject: Re: Argument passing between perl and a C function. Siegfried, Thank you. I am sure it's a dispatch interface. On 6/3/05, Siegfried Heintze <[EMAIL PROTECTED]> wrote: > J, > Is this a custom interface or a dispatch interface? I assumed it was a > dispatch interface. Perl and many other languages like VB and javascript > work well with dispatch interfaces because dispatch interfaces were > specifically designed to accommodate languages like these. > > All dispatch interfaces are various implementations of IDispatch, a set of > function prototypes defined my Microsoft. > > I think you have a custom interface because you are not using SAFEARRAYs. I > doubt Win32::OLE can accommodate custom interfaces. Can you implement your > object using a dispatch or dual interface? You might have to have the author > of your COM object wrap it in C++ with a dispatch interface so you can call > it from perl. Wraping it with a C++ dispatch interface is not hard with > Visual Studio's code generators. I would not want to do it without visual > studio, however. > > Custom interfaces are a big problem. Not even microsoft's most recent > languages, VB.NET and C# can consistently call custom interfaces. I would > not want to try to do so directly in perl. > > Siegfried > > -----Original Message----- > From: J aperlh [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 02, 2005 7:59 PM > To: Siegfried Heintze > Cc: beginners@perl.org > Subject: Re: Argument passing between perl and a C function. > > --------------------------------------------------------------------------- > Thanks for you guys help. > > There is an application written in C language by my colleague. > We are not allowed to share this application for security reason. > > What I am going to do is to call a set of functions in this > application (OLE server) from a PERL script (OLE controller). > > So far, all the functions are works well, except a reference(pointer) > related functions: > --------------------------------------------------------------------------- > BOOL Calculate(BSTR* names, double* values, short number_of_names); > names: a list of names > values: a list of corresponding values, > number_of_names: size of the array > > I don't know that I should pass to this funtion. > Array reference or something else? > > I know that if the OLE controller is in C language, things will be easier, > Passing the first element of the array to this function is ok > > > > On 6/3/05, Siegfried Heintze <[EMAIL PROTECTED]> wrote: > > J, > > You need more information about the function that is contained in the IDL > or > > the type library. Unfortunately, not all COM objects have an IDL file or > > type library. > > > > Both the IDL file and the type library would tell us exactly what the "*" > > means in C because it is ambiguous. The "*" could mean we are passing a > > single value by reference, or multiple values. > > > > I can tell you that it is not looking for a variant, however. > > > > Often COM uses a special data structure called a SAFEARRAY to pass arrays > so > > it could be that your function is looking for scalars, not arrays. > > > > Perhaps there is some documentation? > > > > S > > > > -----Original Message----- > > From: J aperlh [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, June 01, 2005 8:44 PM > > To: beginners@perl.org > > Subject: Argument passing between perl and a C function. > > > > Argument passing between perl and C function. > > > > > > There is C function in a OLE server: > > What kind of variable should I pass to this function? > > ######################################################################### > > BOOL Calculate(BSTR* names, double* values, short number_of_names); > > > > > > I tried the following script, but there is always an error like "Type > > mismatch" ... > > Is there any simple way to pass argument between perl and C function? > > ######################################################################### > > #! perl -W > > > > > > use strict; > > use Win32::OLE; > > use Win32::OLE::Variant; > > > > > > my $names = Variant(VT_BSTR|VT_ARRAY, 3); > > my $values = Variant(VT_R8|VT_ARRAY, 3); > > > > > > $names->Put(['name1', 'name2', 'name3']); > > $values->Put([0, 0, 0]); > > > > > > my $ret = $app->Calculate($names, $values, 3); > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>