Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Transmit an array by reference to a function since Delphi XE2


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 29 - Last Post: Jul 3, 2015 1:44 AM Last Post By: Frederic GIROD
Frederic GIROD

Posts: 18
Registered: 1/15/11
Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2015 12:00 AM
Hi

I have a problem since XE2 (All was fine with 2007) with tranmitting a parameter which is an array by reference to a function, I have this message :
The project Pxxx.exe throw exception class EOleException with message 'Type Mismatch in monParametreFonction for Objet.FunctionCall() Method. Pass an array by Reference'. My code is :

type
  TObRunParams = record
    pIN: OleVariant;
    pOUT: OleVariant;
  end;
 
  TMonObjet = class(...)
  private
    FObApp: OleVariant;
    FObFct: OleVariant;
  public
    property ObApp: OleVariant read FObApp Write FObApp;
    property ObFct: OleVariant read FObFct Write FObFct;
    procedure CallObFct();
  end;
 
procedure TMonObjet.CallObFct;
var
   Params: TObRunParams;
begin
    Params.pIN := VarArrayCreate([0, 1], varVariant);
    Params.pOUT := VarArrayCreate([0, 3], varVariant);
    FObApp := CreateOleObject('Monapp');
    FObFct := FObApp.Function(aFncFileNme, aFncImplNme);
    ObFct.Call(VarArrayRef(aParams.pIN), VarArrayRef(aParams.pOUT)); ==> // Problem
end;


Any idea ?

Thanks for response.
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 3, 2015 5:46 AM   in response to: Frederic GIROD in response to: Frederic GIROD
procedure TMonObjet.CallObFct;
var
Params: TObRunParams;

Params.pIN := VarArrayCreate([0, 1], varVariant);
Params.pOUT := VarArrayCreate([0, 3], varVariant);
ObFct.Call(VarArrayRef(aParams.pIN), VarArrayRef(aParams.pOUT)); ==> // Problem

Is this OK? You declare and fill a local var "Params" and you add in the ObFct.Call procedure "aParams". (With "a" in front of Params..)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 7:31 AM   in response to: Robert Triest in response to: Robert Triest
Is this OK? You declare and fill a local var "Params" and you add in the ObFct.Call procedure "aParams". (With "a" in front of Params..)

Sorry it was a mistake when I copy my code... In fact it's Params which is pass to function....

I have still my problem with this code

procedure TMonObjet.CallObFct;
var
Params: TObRunParams;
 
Params.pIN := VarArrayCreate([0, 1], varVariant);
Params.pOUT := VarArrayCreate([0, 3], varVariant);
ObFct.Call(VarArrayRef(Params.pIN), VarArrayRef(Params.pOUT)); ==> // Problem


Any other idea ?
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 8:19 AM   in response to: Frederic GIROD in response to: Frederic GIROD
No, sorry. You could try to post your question in a form where Remy Lebeau is active...
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 10:01 AM   in response to: Robert Triest in response to: Robert Triest
Robert wrote:

No, sorry. You could try to post your question in a form where Remy
Lebeau is active...

I read most of the Delphi/C++ forums on this server, including this one.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 4, 2015 11:01 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I have a problem since XE2 (All was fine with 2007) with tranmitting a
parameter which is an array by reference to a function, I have this
message :

The project Pxxx.exe throw exception class EOleException with message
'Type Mismatch in monParametreFonction for Objet.FunctionCall()
Method. Pass an array by Reference'.

The root of the problem is that Delphi's OleVariant and Variant types are
different beasts, and you are performing conversions between them, which
causes subtle side effects in some situations, including this one. OleVariant
is OLE-compatible (meaning it is binary-compatible with OLE/COM's native
VARIANT type), but Variant is a custom RTL-implemented type (so it has additional
capabilities that OleVariant does not). Before Variant gained support for
custom types in Delphi 6, it was OLE-compatible, but when custom types were
added than Variant and OleVariant diverged.

All of the functions in the System.Variants unit, including VarArrayCreate()
and VarArrayRef(), operate on Variant only, not on OleVariant. If you assign
a Variant to/from an OleVariant, the RTL performs an implicit conversion
of the data. For most data types, this is an exact copy of the data. But
arrays of Variant elements require a little extra logic, because of Variant's
support for custom data types, which are not OLE-compatible and thus OleVariant
cannot hold them.

The VarArrayRef() function accepts a Variant as input and returns a new Variant
as output, whose VType is the source's VType with the varByRef flag added
to it, and whose VPointer is the source's VPointer adjusted accordingly.
So the output is a true by-reference Variant array, as expected.

However, since you are passing an OleVariant to VarArrayRef(), an implicit
conversion is performed, which makes a copy of the soure array. So you end
up with a Variant that reference the array of a temp Variant that frees its
array when it goes out of scope. COM/OLE arrays are not reference counted,
so watch out for this. But more importantly, when a Variant is assigned
to an OleVariant, a Variant array is custom-copied by the RTL, and that code
does not produce a new by-reference array, even if the source Variant was
marked as varByRef (whether this is an RTL bug or is intentional, I do not
know). The RTL uses varByRef to access the source array correctly, but does
not apply varByRef to the output array.

Thus, you are actually passing your arrays by-value to ObjFct.Call() rather
than by-reference, hense the error.

So how to solve this? The easiest way I can think of is to manually adjust
the OleVariant values you are passing and not let the RTL do it for you:

function OleVarArrayRef(const A: OleVariant): OleVariant;
begin
  if (TVarData(A).VType and varArray) = 0 then
    VarResultCheck(VAR_INVALIDARG);
 
  TVarData(Result).VType := TVarData(A).VType or varByRef;
  if (TVarData(A).VType and varByRef) <> 0 then
    TVarData(Result).VPointer := TVarData(A).VPointer
  else
    TVarData(Result).VPointer := @TVarData(A).VArray;
end;
 
procedure TMonObjet.CallObFct;
var
  Params: TObRunParams;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CreateOleObject('Monapp');
  FObFct := FObApp.Function(aFncFileNme, aFncImplNme);
  ObFct.Call(OleVarArrayRef(aParams.pIN), OleVarArrayRef(aParams.pOUT));
end;


--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2015 2:40 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
So how to solve this? The easiest way I can think of is to manually adjust
the OleVariant values you are passing and not let the RTL do it for you:

function OleVarArrayRef(const A: OleVariant): OleVariant;
begin
  if (TVarData(A).VType and varArray) = 0 then
    VarResultCheck(VAR_INVALIDARG);
 
  TVarData(Result).VType := TVarData(A).VType or varByRef;
  if (TVarData(A).VType and varByRef) <> 0 then
    TVarData(Result).VPointer := TVarData(A).VPointer
  else
    TVarData(Result).VPointer := @TVarData(A).VArray;
end;
 
procedure TMonObjet.CallObFct;
var
  Params: TObRunParams;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CreateOleObject('Monapp');
  FObFct := FObApp.Function(aFncFileNme, aFncImplNme);
  ObFct.Call(OleVarArrayRef(aParams.pIN), OleVarArrayRef(aParams.pOUT));
end;


--
Remy Lebeau (TeamB)

Hi,

Thanks for this explication. Very technical and so not so easy to understand for me (certainly for the english)... I will read again and again tu understand that...

But I try your solution and it doesn't work... I have the same problem... snif...
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2015 3:09 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
So how to solve this? The easiest way I can think of is to manually adjust
the OleVariant values you are passing and not let the RTL do it for you:

function OleVarArrayRef(const A: OleVariant): OleVariant;
begin
  if (TVarData(A).VType and varArray) = 0 then
    VarResultCheck(VAR_INVALIDARG);
 
  TVarData(Result).VType := TVarData(A).VType or varByRef;
  if (TVarData(A).VType and varByRef) <> 0 then
    TVarData(Result).VPointer := TVarData(A).VPointer
  else
    TVarData(Result).VPointer := @TVarData(A).VArray;
end;
 
procedure TMonObjet.CallObFct;
var
  Params: TObRunParams;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CreateOleObject('Monapp');
  FObFct := FObApp.Function(aFncFileNme, aFncImplNme);
  ObFct.Call(OleVarArrayRef(aParams.pIN), OleVarArrayRef(aParams.pOUT));
end;


--
Remy Lebeau (TeamB)

Hi,

Thanks for this explication. Very technical and so not so easy to understand for me (certainly for the english)... I will read again and again tu understand that...

But I try your solution and it doesn't work... I have the same problem... snif...
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2015 1:23 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I try to understand and I don't succeed to go on with my problem so I try to catch the problem by the end...

I need to transmit the references to two arrays of variant to the ObFct.Call(ParmIn, ParmOut). The declaration in C++ of the function Call is
afx_msg SCODE Call(const VARIANT FAR& InParms, const VARIANT FAR& OutParms);


So if I declare my ParmIn as OleVariant and thus define it as
TVarData(ParmIn).VType := varVariant or varArray or varByRef;
TVarData(ParmIn).VPointer := adress of an array of Variant;

Am I in right with this ?

If I continue my thinkink, I need the adresse of an array of Variant, so if I declare VarIn as Variant and define it as
VarIn := VarArrayCreate([0, 1], varVariant);

end thus modify my code this above with
TVarData(ParmIn).VPointer := @TDataVar(VarIn).VArray;


I really don't understand what's wrong with this.....

Really thanks for help.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2015 10:36 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I try to understand and I don't succeed to go on with my problem so I try
to catch the problem by the end...

I think you may need to contact the COM object vendor and find out why it
is not accepting your arrays. You are clearly not sending what the COM object
is actually expecting, but you have not provided any documentation or Type
Library definition to explain what it wants, so we're just guessing at this
point.

I need to transmit the references to two arrays of variant to the
ObFct.Call(ParmIn, ParmOut). The declaration in C++ of the function
Call is

afx_msg SCODE Call(const VARIANT FAR& InParms, const VARIANT FAR& OutParms);

That does not explain what each VARIANT is actually supposed to contain.
What does the declaration of the Call() method look like in the COM object's
Type Library?

So if I declare my ParmIn as OleVariant and thus define it as

TVarData(ParmIn).VType := varVariant or varArray or varByRef;
TVarData(ParmIn).VPointer := adress of an array of Variant;


Am I in right with this ?

When you use varByRef, you need to set VPointer to the address of a pointer
variable that points to the array.

If I continue my thinkink, I need the adresse of an array of Variant,
so if I declare VarIn as Variant and define it as

VarIn := VarArrayCreate([0, 1], varVariant);


end thus modify my code this above with

TVarData(ParmIn).VPointer := @TDataVar(VarIn).VArray;

I already gave you code to do exactly that.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2015 12:57 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
{quote:title=Remy Lebeau (TeamB) wrote:}
I think you may need to contact the COM object vendor and find out why it
is not accepting your arrays. You are clearly not sending what the COM object
is actually expecting, but you have not provided any documentation or Type
Library definition to explain what it wants, so we're just guessing at this
point.
I think that the COM object is expecting is a reference to an array since the message returned is
Type Mismatch in ParmIn for Objet.FunctionCall() Method. Pass an array by Reference

and it's correspond for Delphi 2007 to
var
   pIN, pOUT: OleVariant;
begin
    pIN := VarArrayCreate([0, 1], varVariant);
    pOUT := VarArrayCreate([0, 3], varVariant);
    FObApp := CreateOleObject('Monapp');
    FObFct := FObApp.Function(aFncFileNme, aFncImplNme);
    ObFct.Call(VarArrayRef(pIN), VarArrayRef(pOUT));
end;


I Think the problem is really at the side of Delphi. The object that I try to call never change, I have just change the Delphi's version, and the first code that was writen in Delphi 2007 work fine since many years...

I already gave you code to do exactly that.

Yes thanks for yours explications and your suggestions...

Have you others ?

Really thanks for your help.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2015 12:19 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I think that the COM object is expecting is a reference to an array
since the message returned is

Type Mismatch in ParmIn for Objet.FunctionCall() Method. Pass an
array by Reference

and it's correspond for Delphi 2007 to
<snip>

I already gave you the OleVariant equivilent of that D2007 code. If the
original Variant-based code is working, but the OleVariant-based code is
not, then something else is going on.

I Think the problem is really at the side of Delphi.

You will have to use the debugger to verify that. Maybe something has been
broken in how Delphi dispatches method calls to late-bound objects (when
you access a property/method on an (Ole)Variant, the RTL dispatchs the access
to the object's IDispatch.Invoke() method to do the actual work - thus the
nature of the "late" binding). Maybe Delphi is not passing the OleVariant
values to the method parameters in the lower RTL levels. You would not have
this problem if you were using static-binding instead, as the RTL would not
be involved.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2015 12:31 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I think that the COM object is expecting is a reference to an array
since the message returned is

Type Mismatch in ParmIn for Objet.FunctionCall() Method. Pass an
array by Reference

and it's correspond for Delphi 2007 to
<snip>

I already gave you the OleVariant equivilent of that D2007 code. If the
original Variant-based code is working, but the OleVariant-based code is
not, then something else is going on.

I Think the problem is really at the side of Delphi.

You will have to use the debugger to verify that. Maybe something has been
broken in how the RTL dispatches OLE method calls to late-bound objects (when
you access a property/method on an (Ole)Variant, the RTL calls the object's
IDispatch.Invoke() method to do the actual work - thus the nature of "late"
binding). Maybe Delphi is not passing the OleVariant values to IDispatch.Invoke()
correctly. You would not have this problem if you were using static-binding
instead, as Invoke() would not be involved, you would be calling into the
object methods directly.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 22, 2015 12:27 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
You will have to use the debugger to verify that. Maybe something has been
broken in how the RTL dispatches OLE method calls to late-bound objects (when
you access a property/method on an (Ole)Variant, the RTL calls the object's
IDispatch.Invoke() method to do the actual work - thus the nature of "late"
binding). Maybe Delphi is not passing the OleVariant values to IDispatch.Invoke()
correctly. You would not have this problem if you were using static-binding
instead, as Invoke() would not be involved, you would be calling into the
object methods directly.

--
Remy Lebeau (TeamB)

Thanks Remy.
Can you help me please to tell me what I have to do for that ?
How and what I must verify ?

Thanks for your help.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 22, 2015 1:17 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

Can you help me please to tell me what I have to do for that ?

Import Monapp's Type Library and then use the interfaces it defines, calling
CoCreateInstance() directly instead of CreateOleObject(). Or even let the
IDE create a TComponent wrapper for it.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2015 1:04 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Import Monapp's Type Library
--
Remy Lebeau (TeamB)

How can I achieved do that since Monapp refers to an exe ?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2015 10:31 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

How can I achieved do that since Monapp refers to an exe ?

Any COM object can have a Type Library associated with it, whether it is
implemented as a DLL or an EXE. A Type Library has to be registered with
the OS in order for COM to use it. Go to the "Component | Import Component"
dialog, choose "Import a Type Library", and see if Monapp is on the list.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 24, 2015 11:59 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Go to the "Component | Import Component"
dialog, choose "Import a Type Library", and see if Monapp is on the list.

No it's not... and when I choose Add and go to select my exe, I have an error that it can't import this library type !!!! Rrrrrrrr
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2015 12:40 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

No it's not... and when I choose Add and go to select my exe, I
have an error that it can't import this library type !!!! Rrrrrrrr

I never said the exe file did have a TypeLibrary, I said it might have
one. It is also possible that the TypeLibrary might be in a separate TLB
file instead. You could go into the Registry and look up the registeration
for the 'Monapp' COM object and see if it has a TypeLibrary assigned to it.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2015 2:34 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
I never said the exe file did have a TypeLibrary, I said it might have
one. It is also possible that the TypeLibrary might be in a separate TLB
file instead. You could go into the Registry and look up the registeration
for the 'Monapp' COM object and see if it has a TypeLibrary assigned to it.

Sorry it was not what I would to say... It's my bad english !!!! I would say that I don't see My exe in the Library list...

What I see in the registry under the CLSID is :
InprocHandler32 : ole32.dll
LocalServer32 : R:\ob600RC.exe
ProgID : obRunOLE600RC.app

The ProdID correspond the Myapp that I specify when I create my OleObjet
FObApp := CreateOleObject('ObRunOLE600RC.App');
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 25, 2015 4:47 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I would say that I don't see My exe in the Library list...

No, you wouldn't.

What I see in the registry under the CLSID is :
InprocHandler32 : ole32.dll
LocalServer32 : R:\ob600RC.exe
ProgID : obRunOLE600RC.app

The ProdID correspond the Myapp that I specify when I create my OleObjet

OK, so does the CLSID key also have a TypeLib subkey? If so, then it will
point at the guid of the TypeLibrary, which you can then find under HKCR\TypeLib,
and from there you will have the filename of the executable that contains
the TypeLibrary. You can then import that file. However, if there is a
TypeLib registered, it should already be included in the importer's list
of available TypeLibraries to pick from. So you would just have to find
the one that belongs to the 'ObRunOLE600RC.App' progid.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 26, 2015 6:14 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Frederic wrote:

What I see in the registry under the CLSID is :
InprocHandler32 : ole32.dll
LocalServer32 : R:\ob600RC.exe
ProgID : obRunOLE600RC.app

The ProdID correspond the Myapp that I specify when I create my OleObjet

OK, so does the CLSID key also have a TypeLib subkey?
--
Remy Lebeau (TeamB)
Sorry but only the keys that I tell are present...

Now it's strange but I've just already found a library type that seam's to be in relation with my application (Since it' wasn't present before... that's really strange !!!!) but I don't know how ???? I have this tlb when i import this one :
unit OBRTATLLib_TLB;
 
// ************************************************************************ //
// AVERTISSEMENT
// -------
// Les types déclarés dans ce fichier ont été générés à partir de données lues
// depuis la bibliothèque de types. Si cette dernière (via une autre bibliothèque de types
// s'y référant) est explicitement ou indirectement ré-importée, ou la commande "Actualiser"
// de l'éditeur de bibliothèque de types est activée lors de la modification de la bibliothèque
// de types, le contenu de ce fichier sera régénéré et toutes les modifications
// manuellement apportées seront perdues.
// ************************************************************************ //
 
// $Rev: 45604 $
// Fichier généré le 26/06/2015 14:49:54 depuis la bibliothèque de types ci-dessous.
 
// ************************************************************************  //
// Biblio. types : \\ACGFIC01\PLEXDEVRUNTIME\ob600COM_TX.dll (1)
// LIBID : {E1F79D5D-04B0-4A66-9506-E2B319ABEB35}
// LCID : 0
// Fichier d'aide : R:\PlexMTS.chm
// Chaîne d'aide : CA Plex Release DLL server for MTS
// DepndLst : 
//   (1) v2.0 stdole, (C:\Windows\SysWOW64\stdole2.tlb)
// SYS_KIND: SYS_WIN32
// ************************************************************************ //
{$TYPEDADDRESS OFF} // L'unité doit être compilée sans pointeur à type contrôlé.  
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
 
interface
 
uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX;
  
// *********************************************************************//
// GUIDS déclarés dans la bibliothèque de types. Préfixes utilisés:        
//   Bibliothèques de types : LIBID_xxxx                                      
//   CoClasses              : CLASS_xxxx                                      
//   Interfaces DISP        : DIID_xxxx                                       
//   Interfaces Non-DISP    : IID_xxxx                                        
// *********************************************************************//
const
  // Versions mineure et majeure de la bibliothèque de types
  OBRTATLLibMajorVersion = 6;
  OBRTATLLibMinorVersion = 0;
 
  LIBID_OBRTATLLib: TGUID = '{E1F79D5D-04B0-4A66-9506-E2B319ABEB35}';
 
  IID_IObCOM_TXApp: TGUID = '{E1F79D5D-04B1-4A66-9506-E2B319ABEB35}';
  CLASS_ObCOM_TXApp: TGUID = '{E1F79D5D-04B2-4A66-9506-E2B319ABEB35}';
  IID_INewTransactionFunction: TGUID = '{E1F79D5D-04B3-4A66-9506-E2B319ABEB35}';
  IID_IRequiresTransactionFunction: TGUID = '{E1F79D5D-04B5-4A66-9506-E2B319ABEB35}';
  IID_ISupportsTransactionFunction: TGUID = '{E1F79D5D-04B7-4A66-9506-E2B319ABEB35}';
  IID_IDoesNotSupportTransactionFunction: TGUID = '{E1F79D5D-04B9-4A66-9506-E2B319ABEB35}';
  CLASS_NewTransactionFunction: TGUID = '{E1F79D5D-04B4-4A66-9506-E2B319ABEB35}';
  CLASS_RequiresTransactionFunction: TGUID = '{E1F79D5D-04B6-4A66-9506-E2B319ABEB35}';
  CLASS_SupportsTransactionFunction: TGUID = '{E1F79D5D-04B8-4A66-9506-E2B319ABEB35}';
  CLASS_DoesNotSupportTransactionFunction: TGUID = '{E1F79D5D-04BA-4A66-9506-E2B319ABEB35}';
type
 
// *********************************************************************//
// Déclaration Forward des types définis dans la bibliothèque de types                     
// *********************************************************************//
  IObCOM_TXApp = interface;
  IObCOM_TXAppDisp = dispinterface;
  INewTransactionFunction = interface;
  INewTransactionFunctionDisp = dispinterface;
  IRequiresTransactionFunction = interface;
  IRequiresTransactionFunctionDisp = dispinterface;
  ISupportsTransactionFunction = interface;
  ISupportsTransactionFunctionDisp = dispinterface;
  IDoesNotSupportTransactionFunction = interface;
  IDoesNotSupportTransactionFunctionDisp = dispinterface;
 
// *********************************************************************//
// Déclaration de CoClasses définies dans la bibliothèque de types        
// (REMARQUE: On affecte chaque CoClasse à son Interface par défaut)      
// *********************************************************************//
  ObCOM_TXApp = IObCOM_TXApp;
  NewTransactionFunction = INewTransactionFunction;
  RequiresTransactionFunction = IRequiresTransactionFunction;
  SupportsTransactionFunction = ISupportsTransactionFunction;
  DoesNotSupportTransactionFunction = IDoesNotSupportTransactionFunction;
 
 
// *********************************************************************//
// Déclaration de structures, d'unions et d'alias.                         
// *********************************************************************//
  PWideString1 = ^WideString; {*}
  POleVariant1 = ^OleVariant; {*}
  PInteger1 = ^Integer; {*}
 
 
// *********************************************************************//
// Interface :   IObCOM_TXApp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B1-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IObCOM_TXApp = interface(IDispatch)
    ['{E1F79D5D-04B1-4A66-9506-E2B319ABEB35}']
    function Get_environmentKey: WideString; safecall;
    procedure Set_environmentKey(const pVal: WideString); safecall;
    function NewTransactionFunction(var fileNME: WideString; var implementationNME: WideString): INewTransactionFunction; safecall;
    function RequiresTransactionFunction(var fileNME: WideString; var implementationNME: WideString): IRequiresTransactionFunction; safecall;
    function SupportsTransactionFunction(var fileNME: WideString; var implementationNME: WideString): ISupportsTransactionFunction; safecall;
    function DoesNotSupportTransactionFunction(var fileNME: WideString; 
                                               var implementationNME: WideString): IDoesNotSupportTransactionFunction; safecall;
    property environmentKey: WideString read Get_environmentKey write Set_environmentKey;
  end;
 
// *********************************************************************//
// DispIntf :    IObCOM_TXAppDisp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B1-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IObCOM_TXAppDisp = dispinterface
    ['{E1F79D5D-04B1-4A66-9506-E2B319ABEB35}']
    property environmentKey: WideString dispid 1;
    function NewTransactionFunction(var fileNME: WideString; var implementationNME: WideString): INewTransactionFunction; dispid 2;
    function RequiresTransactionFunction(var fileNME: WideString; var implementationNME: WideString): IRequiresTransactionFunction; dispid 3;
    function SupportsTransactionFunction(var fileNME: WideString; var implementationNME: WideString): ISupportsTransactionFunction; dispid 4;
    function DoesNotSupportTransactionFunction(var fileNME: WideString; 
                                               var implementationNME: WideString): IDoesNotSupportTransactionFunction; dispid 5;
  end;
 
// *********************************************************************//
// Interface :   INewTransactionFunction
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B3-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  INewTransactionFunction = interface(IDispatch)
    ['{E1F79D5D-04B3-4A66-9506-E2B319ABEB35}']
    function Get_fileNME: WideString; safecall;
    procedure Set_fileNME(const pVal: WideString); safecall;
    function Get_implementationNME: WideString; safecall;
    procedure Set_implementationNME(const pVal: WideString); safecall;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); safecall;
    procedure SetAppContext(var pVal: Integer); safecall;
    property fileNME: WideString read Get_fileNME write Set_fileNME;
    property implementationNME: WideString read Get_implementationNME write Set_implementationNME;
  end;
 
// *********************************************************************//
// DispIntf :    INewTransactionFunctionDisp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B3-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  INewTransactionFunctionDisp = dispinterface
    ['{E1F79D5D-04B3-4A66-9506-E2B319ABEB35}']
    property fileNME: WideString dispid 1;
    property implementationNME: WideString dispid 2;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); dispid 3;
    procedure SetAppContext(var pVal: Integer); dispid 4;
  end;
 
// *********************************************************************//
// Interface :   IRequiresTransactionFunction
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B5-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IRequiresTransactionFunction = interface(IDispatch)
    ['{E1F79D5D-04B5-4A66-9506-E2B319ABEB35}']
    function Get_fileNME: WideString; safecall;
    procedure Set_fileNME(const pVal: WideString); safecall;
    function Get_implementationNME: WideString; safecall;
    procedure Set_implementationNME(const pVal: WideString); safecall;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); safecall;
    procedure SetAppContext(var pVal: Integer); safecall;
    property fileNME: WideString read Get_fileNME write Set_fileNME;
    property implementationNME: WideString read Get_implementationNME write Set_implementationNME;
  end;
 
// *********************************************************************//
// DispIntf :    IRequiresTransactionFunctionDisp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B5-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IRequiresTransactionFunctionDisp = dispinterface
    ['{E1F79D5D-04B5-4A66-9506-E2B319ABEB35}']
    property fileNME: WideString dispid 1;
    property implementationNME: WideString dispid 2;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); dispid 3;
    procedure SetAppContext(var pVal: Integer); dispid 4;
  end;
 
// *********************************************************************//
// Interface :   ISupportsTransactionFunction
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B7-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  ISupportsTransactionFunction = interface(IDispatch)
    ['{E1F79D5D-04B7-4A66-9506-E2B319ABEB35}']
    function Get_fileNME: WideString; safecall;
    procedure Set_fileNME(const pVal: WideString); safecall;
    function Get_implementationNME: WideString; safecall;
    procedure Set_implementationNME(const pVal: WideString); safecall;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); safecall;
    procedure SetAppContext(var pVal: Integer); safecall;
    property fileNME: WideString read Get_fileNME write Set_fileNME;
    property implementationNME: WideString read Get_implementationNME write Set_implementationNME;
  end;
 
// *********************************************************************//
// DispIntf :    ISupportsTransactionFunctionDisp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B7-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  ISupportsTransactionFunctionDisp = dispinterface
    ['{E1F79D5D-04B7-4A66-9506-E2B319ABEB35}']
    property fileNME: WideString dispid 1;
    property implementationNME: WideString dispid 2;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); dispid 3;
    procedure SetAppContext(var pVal: Integer); dispid 4;
  end;
 
// *********************************************************************//
// Interface :   IDoesNotSupportTransactionFunction
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B9-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IDoesNotSupportTransactionFunction = interface(IDispatch)
    ['{E1F79D5D-04B9-4A66-9506-E2B319ABEB35}']
    function Get_fileNME: WideString; safecall;
    procedure Set_fileNME(const pVal: WideString); safecall;
    function Get_implementationNME: WideString; safecall;
    procedure Set_implementationNME(const pVal: WideString); safecall;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); safecall;
    procedure SetAppContext(var pVal: Integer); safecall;
    property fileNME: WideString read Get_fileNME write Set_fileNME;
    property implementationNME: WideString read Get_implementationNME write Set_implementationNME;
  end;
 
// *********************************************************************//
// DispIntf :    IDoesNotSupportTransactionFunctionDisp
// Indicateurs : (4416) Dual OleAutomation Dispatchable
// GUID :        {E1F79D5D-04B9-4A66-9506-E2B319ABEB35}
// *********************************************************************//
  IDoesNotSupportTransactionFunctionDisp = dispinterface
    ['{E1F79D5D-04B9-4A66-9506-E2B319ABEB35}']
    property fileNME: WideString dispid 1;
    property implementationNME: WideString dispid 2;
    procedure Call(const InParms: OleVariant; const OutParms: OleVariant); dispid 3;
    procedure SetAppContext(var pVal: Integer); dispid 4;
  end;
 
// *********************************************************************//
// La classe CoObCOM_TXApp fournit une méthode Create et CreateRemote pour
// créer des instances de l'interface par défaut IObCOM_TXApp exposée
// par la CoClasse ObCOM_TXApp. Les fonctions sont destinées à être utilisées par
// les clients désirant automatiser les objets CoClasse exposés par
// le serveur de cette bibliothèque de types.
// *********************************************************************//
  CoObCOM_TXApp = class
    class function Create: IObCOM_TXApp;
    class function CreateRemote(const MachineName: string): IObCOM_TXApp;
  end;
 
// *********************************************************************//
// La classe CoNewTransactionFunction fournit une méthode Create et CreateRemote pour
// créer des instances de l'interface par défaut INewTransactionFunction exposée
// par la CoClasse NewTransactionFunction. Les fonctions sont destinées à être utilisées par
// les clients désirant automatiser les objets CoClasse exposés par
// le serveur de cette bibliothèque de types.
// *********************************************************************//
  CoNewTransactionFunction = class
    class function Create: INewTransactionFunction;
    class function CreateRemote(const MachineName: string): INewTransactionFunction;
  end;
 
// *********************************************************************//
// La classe CoRequiresTransactionFunction fournit une méthode Create et CreateRemote pour
// créer des instances de l'interface par défaut IRequiresTransactionFunction exposée
// par la CoClasse RequiresTransactionFunction. Les fonctions sont destinées à être utilisées par
// les clients désirant automatiser les objets CoClasse exposés par
// le serveur de cette bibliothèque de types.
// *********************************************************************//
  CoRequiresTransactionFunction = class
    class function Create: IRequiresTransactionFunction;
    class function CreateRemote(const MachineName: string): IRequiresTransactionFunction;
  end;
 
// *********************************************************************//
// La classe CoSupportsTransactionFunction fournit une méthode Create et CreateRemote pour
// créer des instances de l'interface par défaut ISupportsTransactionFunction exposée
// par la CoClasse SupportsTransactionFunction. Les fonctions sont destinées à être utilisées par
// les clients désirant automatiser les objets CoClasse exposés par
// le serveur de cette bibliothèque de types.
// *********************************************************************//
  CoSupportsTransactionFunction = class
    class function Create: ISupportsTransactionFunction;
    class function CreateRemote(const MachineName: string): ISupportsTransactionFunction;
  end;
 
// *********************************************************************//
// La classe CoDoesNotSupportTransactionFunction fournit une méthode Create et CreateRemote pour
// créer des instances de l'interface par défaut IDoesNotSupportTransactionFunction exposée
// par la CoClasse DoesNotSupportTransactionFunction. Les fonctions sont destinées à être utilisées par
// les clients désirant automatiser les objets CoClasse exposés par
// le serveur de cette bibliothèque de types.
// *********************************************************************//
  CoDoesNotSupportTransactionFunction = class
    class function Create: IDoesNotSupportTransactionFunction;
    class function CreateRemote(const MachineName: string): IDoesNotSupportTransactionFunction;
  end;
 
implementation
 
uses System.Win.ComObj;
 
class function CoObCOM_TXApp.Create: IObCOM_TXApp;
begin
  Result := CreateComObject(CLASS_ObCOM_TXApp) as IObCOM_TXApp;
end;
 
class function CoObCOM_TXApp.CreateRemote(const MachineName: string): IObCOM_TXApp;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_ObCOM_TXApp) as IObCOM_TXApp;
end;
 
class function CoNewTransactionFunction.Create: INewTransactionFunction;
begin
  Result := CreateComObject(CLASS_NewTransactionFunction) as INewTransactionFunction;
end;
 
class function CoNewTransactionFunction.CreateRemote(const MachineName: string): INewTransactionFunction;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_NewTransactionFunction) as INewTransactionFunction;
end;
 
class function CoRequiresTransactionFunction.Create: IRequiresTransactionFunction;
begin
  Result := CreateComObject(CLASS_RequiresTransactionFunction) as IRequiresTransactionFunction;
end;
 
class function CoRequiresTransactionFunction.CreateRemote(const MachineName: string): IRequiresTransactionFunction;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_RequiresTransactionFunction) as IRequiresTransactionFunction;
end;
 
class function CoSupportsTransactionFunction.Create: ISupportsTransactionFunction;
begin
  Result := CreateComObject(CLASS_SupportsTransactionFunction) as ISupportsTransactionFunction;
end;
 
class function CoSupportsTransactionFunction.CreateRemote(const MachineName: string): ISupportsTransactionFunction;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_SupportsTransactionFunction) as ISupportsTransactionFunction;
end;
 
class function CoDoesNotSupportTransactionFunction.Create: IDoesNotSupportTransactionFunction;
begin
  Result := CreateComObject(CLASS_DoesNotSupportTransactionFunction) as IDoesNotSupportTransactionFunction;
end;
 
class function CoDoesNotSupportTransactionFunction.CreateRemote(const MachineName: string): IDoesNotSupportTransactionFunction;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_DoesNotSupportTransactionFunction) as IDoesNotSupportTransactionFunction;
end;
 
end.


So now how can I find what's the origine of my problem with this new element ?

Edited by: Frederic GIROD on Jun 26, 2015 6:50 AM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 26, 2015 11:29 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

Sorry but only the keys that I tell are present...

Then there is no Type Library associated with that COM object.

Now it's strange but I've just already found a library type that
seam's to be in relation with my application (Since it' wasn't present
before... that's really strange !!!!) but I don't know how ????

Neither do I, but it was clearly generated from ob600COM_TX.dll.

I have this tlb when i import this one :

Try something like this:

uses
  OBRTATLLib_TLB;
 
TMonObjet = class(...)
private
  FObApp: IObCOM_TXApp;
  FObFct: INewTransactionFunction;
public
  property ObApp: IObCOM_TXApp read FObApp Write FObApp;
  property ObFct: INewTransactionFunction read FObFct Write FObFct;
  procedure CallObFct();
end;
 
procedure TMonObjet.CallObFct;
var
  Params: OleVariant;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CoObCOM_TXApp.Create;
  FObFct := FObApp.NewTransactionFunction(aFncFileNme, aFncImplNme);
  FObFct.Call(aParams.pIN, aParams.pOUT); // or OleVarArrayRef() if needed...
end;


if NewTransactionFunction() is not the function you want, there are also
RequiresTransactionFunction(), SupportsTransactionFunction(), and DoesNotSupportTransactionFunction()
functions available.

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2015 12:14 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Try something like this:

uses
  OBRTATLLib_TLB;
 
TMonObjet = class(...)
private
  FObApp: IObCOM_TXApp;
  FObFct: INewTransactionFunction;
public
  property ObApp: IObCOM_TXApp read FObApp Write FObApp;
  property ObFct: INewTransactionFunction read FObFct Write FObFct;
  procedure CallObFct();
end;
 
procedure TMonObjet.CallObFct;
var
  Params: OleVariant;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CoObCOM_TXApp.Create;
  FObFct := FObApp.NewTransactionFunction(aFncFileNme, aFncImplNme);
  FObFct.Call(aParams.pIN, aParams.pOUT); // or OleVarArrayRef() if needed...
end;


if NewTransactionFunction() is not the function you want, there are also
RequiresTransactionFunction(), SupportsTransactionFunction(), and DoesNotSupportTransactionFunction()
functions available.

Rrrrrrrr, I have a class exception $C0000005 with the message 'violation access at 0x0....... read of adress 0x00000000' on the line
FObFct := FObApp.NewTransactionFunction(aFncFileNme, aFncImplNme);

How can I found the problem with this king of message ?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2015 11:36 AM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

Rrrrrrrr, I have a class exception $C0000005 with the message
'violation access at 0x0....... read of adress 0x00000000' on the line

AVs that occur at/near address $00000000 usually mean you are accessing a
nil pointer. Make sure FObApp is not nil before calling NewTransactionFunction().

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2015 12:23 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
AVs that occur at/near address $00000000 usually mean you are accessing a
nil pointer. Make sure FObApp is not nil before calling NewTransactionFunction().

No it's not. I have for FObApp
Pointer($D57AAC) as IObCOM_TXApp
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2015 2:43 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

No it's not. I have for FObApp

Pointer($D57AAC) as IObCOM_TXApp

Are you sure the AV is occurring on the line that is calling FObApp.NewTransactionFunction(),
and not on the line that is calling FObFct.Call()?

--
Remy Lebeau (TeamB)
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 3, 2015 1:44 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Are you sure the AV is occurring on the line that is calling FObApp.NewTransactionFunction(),
and not on the line that is calling FObFct.Call()?

Yes I think since I put two breakpoints on this two lines and the programm stop on FObApp.NewTransactionFunction() but not on FObFct.Call()... and when the exception appears et I choose Stop on the message, the debugguer stop on the line FObApp.NewTransactionFunction()...
Frederic GIROD

Posts: 18
Registered: 1/15/11
Re: Transmit an array by reference to a function since Delphi XE2[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2015 1:17 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Try something like this:

uses
  OBRTATLLib_TLB;
 
TMonObjet = class(...)
private
  FObApp: IObCOM_TXApp;
  FObFct: INewTransactionFunction;
public
  property ObApp: IObCOM_TXApp read FObApp Write FObApp;
  property ObFct: INewTransactionFunction read FObFct Write FObFct;
  procedure CallObFct();
end;
 
procedure TMonObjet.CallObFct;
var
  Params: OleVariant;
begin
  Params.pIN := VarArrayCreate([0, 1], varVariant);
  Params.pOUT := VarArrayCreate([0, 3], varVariant);
  FObApp := CoObCOM_TXApp.Create;
  FObFct := FObApp.NewTransactionFunction(aFncFileNme, aFncImplNme);
  FObFct.Call(aParams.pIN, aParams.pOUT); // or OleVarArrayRef() if needed...
end;


if NewTransactionFunction() is not the function you want, there are also
RequiresTransactionFunction(), SupportsTransactionFunction(), and DoesNotSupportTransactionFunction()
functions available.

Rrrrrrrr, I have a class exception $C0000005 with the message 'violation access at 0x0....... read of adress 0x00000000' on the line
FObFct := FObApp.NewTransactionFunction(aFncFileNme, aFncImplNme);

How can I found the problem with this king of message ?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Transmit an array by reference to a function since Delphi XE2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 23, 2015 11:55 PM   in response to: Frederic GIROD in response to: Frederic GIROD
Frederic wrote:

I think that the COM object is expecting is a reference to an array
since the message returned is

Type Mismatch in ParmIn for Objet.FunctionCall() Method. Pass an
array by Reference

and it's correspond for Delphi 2007 to
<snip>

I already gave you the OleVariant equivilent of that D2007 code. If the
original Variant-based code is working, but the OleVariant-based code is
not, then something else is going on.

I Think the problem is really at the side of Delphi.

You will have to use the debugger to verify that. Maybe something has been
broken in how the RTL dispatches OLE method calls to late-bound objects (when
you access a property/method on an (Ole)Variant, the RTL calls the object's
IDispatch.Invoke() method to do the actual work - thus the nature of "late"
binding). Maybe Delphi is not passing the OleVariant values to IDispatch.Invoke()
correctly. You would not have this problem if you were using static-binding
instead, as Invoke() would not be involved, you would be calling into the
object methods directly.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02