BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use particular COM object

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Aaron Miles
Guest





PostPosted: Thu Dec 02, 2004 1:13 pm    Post subject: How to use particular COM object Reply with quote



Hello Delphi experts,

Forgive me if this is overly simple, but I am just starting to play around
with COM and I am getting confused. I have used OLE Automation before and
have written many an app that uses say for example the office libraries
without incident but this has got me perplexed.

Below are some snippets of what I am trying to 'use' ( there are more
functions but this is the one I wish to try first )

const
// TypeLibrary Major and minor versions
ECIWRAPLibMajorVersion = 1;
ECIWRAPLibMinorVersion = 0;

LIBID_ECIWRAPLib: TGUID = '{50AC14A2-4C38-11D2-8670-0000F87A323C}';

IID_IUtilityWrapper: TGUID = '{50AC14AF-4C38-11D2-8670-0000F87A323C}';
IID_IEventWrapper: TGUID = '{50AC14B0-4C38-11D2-8670-0000F87A323C}';
IID_IUnitWrapper: TGUID = '{50AC14B1-4C38-11D2-8670-0000F87A323C}';
IID_ICDConfig: TGUID = '{514F0993-DF3B-11D3-AC51-00C04FBCDBE2}';
IID_IEventData: TGUID = '{97C0F830-5CE1-11D2-8677-0000F87A323C}';
CLASS_ECIWrapper: TGUID = '{50AC14B2-4C38-11D2-8670-0000F87A323C}';
IID_IUnitData: TGUID = '{55BD93B2-5F2E-11D2-8678-0000F87A323C}';
CLASS_EventData: TGUID = '{97C0F831-5CE1-11D2-8677-0000F87A323C}';
CLASS_UnitData: TGUID = '{55BD93B3-5F2E-11D2-8678-0000F87A323C}';
CLASS_CDConfig: TGUID = '{514F0992-DF3B-11D3-AC51-00C04FBCDBE2}';
IID_ICDConfigItem: TGUID = '{514F0995-DF3B-11D3-AC51-00C04FBCDBE2}';
CLASS_CDConfigItem: TGUID = '{514F0996-DF3B-11D3-AC51-00C04FBCDBE2}';

// *********************************************************************//
// The Class CoECIWrapper provides a Create and CreateRemote method to
// create instances of the default interface IUtilityWrapper exposed by
// the CoClass ECIWrapper. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoECIWrapper = class
class function Create: IUtilityWrapper;
class function CreateRemote(const MachineName: string): IUtilityWrapper;
end;

IUnitWrapper = interface(IDispatch)
['{50AC14B1-4C38-11D2-8670-0000F87A323C}']
function Dispatch(const sOperatorTermName: WideString; iOperatroId:
SYSINT;
const bstrUnitId: WideString; const bstrNum1:
WideString;
const bstrComment: WideString; const bstrLocation:
WideString;
const bstrMileage: WideString): Integer; safecall;




My code is as follows:

procedure TForm1.Button1Click(Sender: TObject);
var
i: iunitwrapper;
e: ECIWrapper;
begin
e := coEciWrapper.Create;
e.Initialise('disp', 0, '');
e.SetOperatorDetails('saints', 820);
e.SendMessageToTerminal('fs2000', 820, datetimetostr(now), 'test', '1',
100, 'saints');
i.Dispatch('saints',820,'1222','R04150606','Test','Location','0');
<-------Fails here
end;


I really need the dispatch function to work but I cannot figure out how...
none of the EciWrapper methods have an function to pass a result of that
type .... I.E what I have done in the past with some classes is


EG: b := a.Units as IListenUnits

But I canont find any such mechanisms in the tlb file ....


could someone please point me in the right direction?

Best Wishes and Thanks,
Aaron Miles



Back to top
Oliver
Guest





PostPosted: Thu Dec 02, 2004 1:45 pm    Post subject: Re: How to use particular COM object Reply with quote




Hello,

although i recently got a COM object using dispinterfaces to work, i´m still far from being an expert (i.e it works, but i still do not understand all the details why it works Smile).
Beside a typelibrary, i use an "EventSink" unit which by the way has been generated by an EventSinkImpUtility which was written by Binh Ly (bly (AT) techvanguards (DOT) com). This EventSink unit declares a class

TAMVnBridgeEventsBaseSink
= class (TComponent, IUnknown, IDispatch)

which i use as a component on a form.
In my main unit i use:

gObjFactory: _AMVnClassFactory;
gObjSyncClass: _AMVnSync;

gObjFactory := CoAMVnClassFactory.Create;
gObjSyncClass:= gObjFactory.GetAMVnSync;
AMVnBridgeAMVnSync1.Connect(gObjSyncClass);

CoAMVnClassFactory is part of the typelibrary. The method GetAMVnSync is declared in the typelibrary too:

_AMVnClassFactory = interface(IDispatch)
['{97692FF8-1B95-4AE4-A4F9-99E4FAC3587D}']
function GetAMVnPlugin: _AMVnPlugin; safecall;
function GetAMVnSync: _AMVnSync; safecall;
procedure ShutDown; safecall;
end;

But the Connect method comes from the EventSink (the generated unit)! Im not sure how all this relates to your COM object, but maybe the hint "EventSink" is useful (maybe not...)

regards

Oliver
Back to top
Oliver
Guest





PostPosted: Thu Dec 02, 2004 2:00 pm    Post subject: Re: How to use particular COM object Reply with quote




Hi

correction

i dont use the TAMVnBridgeEventsBaseSink as a component on a form, but the TAMVnBridgeAMVnSync (which is the "SinkComponent")

//SinkComponent//
TAMVnBridgeAMVnSync = class (TAMVnBridgeEventsBaseSink
//ISinkInterface//)

which publishes the events (which i use in my main form).
But note that these classes are part of the generated EventSink (i didnt type them myself).

kind regards

Oliver

PS: by typing my replies i recognize that i dont fully understand what im using here, but i wanted to help anyway :)


"Oliver" <o.maas (AT) nospam_metrohm (DOT) de> wrote:
Quote:

Hello,

although i recently got a COM object using dispinterfaces to work, i´m still far from being an expert (i.e it works, but i still do not understand all the details why it works Smile).
Beside a typelibrary, i use an "EventSink" unit which by the way has been generated by an EventSinkImpUtility which was written by Binh Ly (bly (AT) techvanguards (DOT) com). This EventSink unit declares a class

TAMVnBridgeEventsBaseSink
= class (TComponent, IUnknown, IDispatch)

which i use as a component on a form.
In my main unit i use:

gObjFactory: _AMVnClassFactory;
gObjSyncClass: _AMVnSync;

gObjFactory := CoAMVnClassFactory.Create;
gObjSyncClass:= gObjFactory.GetAMVnSync;
AMVnBridgeAMVnSync1.Connect(gObjSyncClass);

CoAMVnClassFactory is part of the typelibrary. The method GetAMVnSync is declared in the typelibrary too:

_AMVnClassFactory = interface(IDispatch)
['{97692FF8-1B95-4AE4-A4F9-99E4FAC3587D}']
function GetAMVnPlugin: _AMVnPlugin; safecall;
function GetAMVnSync: _AMVnSync; safecall;
procedure ShutDown; safecall;
end;

But the Connect method comes from the EventSink (the generated unit)! Im not sure how all this relates to your COM object, but maybe the hint "EventSink" is useful (maybe not...)

regards

Oliver


Back to top
John Carlyle-Clarke
Guest





PostPosted: Thu Dec 02, 2004 3:46 pm    Post subject: Re: How to use particular COM object Reply with quote

"Aaron Miles" <miles3719(at)Msn.com> wrote in
news:41af14df (AT) newsgroups (DOT) borland.com:

{snip}

Quote:
CoECIWrapper = class
class function Create: IUtilityWrapper;
class function CreateRemote(const MachineName: string):
IUtilityWrapper;
end;

IUnitWrapper = interface(IDispatch)
['{50AC14B1-4C38-11D2-8670-0000F87A323C}']
function Dispatch(const sOperatorTermName: WideString;
iOperatroId: SYSINT;
const bstrUnitId: WideString;
const bstrNum1: WideString;
const bstrComment: WideString;
const bstrLocation: WideString;
const bstrMileage: WideString): Integer; safecall;

My code is as follows:

procedure TForm1.Button1Click(Sender: TObject);
var
i: iunitwrapper;
e: ECIWrapper;
begin
e := coEciWrapper.Create;
e.Initialise('disp', 0, '');
e.SetOperatorDetails('saints', 820);
e.SendMessageToTerminal('fs2000', 820, datetimetostr(now),
'test', '1',
100, 'saints');
i.Dispatch('saints',820,'1222','R04150606','Test','Location','0');
-------Fails here
end;


You haven't shown where the type ECIWrapper is defined. Also, in
this sample, i is uninitialized.

When you say "Fails here" what do you mean.. fails to compile? Fails
to run? What is the error?

Quote:
I really need the dispatch function to work but I cannot figure
out how...

none of the EciWrapper methods have an function to pass
a result of that type

What type?

If you mean IUtilityWrapper, then the function you are looking for
is CoEciWrapper.Create..


Back to top
Aaron Miles
Guest





PostPosted: Thu Dec 02, 2004 11:43 pm    Post subject: Re: How to use particular COM object Reply with quote

Quote:

You haven't shown where the type ECIWrapper is defined. Also, in
this sample, i is uninitialized.

When you say "Fails here" what do you mean.. fails to compile? Fails
to run? What is the error?

I really need the dispatch function to work but I cannot figure
out how...

none of the EciWrapper methods have an function to pass
a result of that type

What type?

If you mean IUtilityWrapper, then the function you are looking for
is CoEciWrapper.Create..


John,

Forgive me. ...... my eyelids got the better of me and the brain was not in
gear.

The error I get when trying to use the I.Dispatch method is "Access
Violation in Project1.exe Address:00000000"

I realise that I is uninitialized but the there is no 'create' method (I
assume create is what you are referring to)

CoECIWrapper = class
class function Create: IUtilityWrapper;
class function CreateRemote(const MachineName: string): IUtilityWrapper;
end;


I have found a few examples on the internet that refer to coClass so I
reimported the type library without the component wrapper created so it more
resembles the examples
so the code that I have at the moment is

var
e: eciwrapper;
i: iUnitWrapper;
begin
try
begin
coinitialize(nil);
e := coeciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000',820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is a
subject', '9', 0, 'ras1admin');
i.Dispatch('fs2000',820',1221','R234343433'); <--- Failes here with
Access Violation in Project1.exe Read of Address :000000000
end
except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;
end.


The problem is that I cannot find how to initialize the iUnitWrapper
interface (is that what its called?) so that I can utilise its methods
which I ultimatly want to use like dispatch, enroute, arrive etc..
Thanks
Cheers,
Aaron



Back to top
John Carlyle-Clarke
Guest





PostPosted: Fri Dec 03, 2004 9:37 am    Post subject: Re: How to use particular COM object Reply with quote

"Aaron Miles" <miles3719(at)msn.com> wrote in
news:41afa8b8$1 (AT) newsgroups (DOT) borland.com:

Quote:
I have found a few examples on the internet that refer to coClass
so I reimported the type library without the component wrapper
created so it more resembles the examples
so the code that I have at the moment is

var
e: eciwrapper;
i: iUnitWrapper;
begin
try
begin
coinitialize(nil);
e := coeciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000',820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is
a
subject', '9', 0, 'ras1admin');
i.Dispatch('fs2000',820',1221','R234343433'); <--- Failes
here with
Access Violation in Project1.exe Read of Address :000000000
end
except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;
end.


Quote:
The problem is that I cannot find how to initialize the
iUnitWrapper interface (is that what its called?) so that I can
utilise its methods which I ultimatly want to use like dispatch,
enroute, arrive etc.. Thanks

OK, I understand the problem now. The type library you emailed me
contains these CoClasses:

CoECIWrapper, CoEventData, CoUnitData, CoCDConfig, CoCDConfigItem

Each of these has a default interface, but they also may support one
or more other interfaces. All COM interfaces derive from IUnknown
(look in the MSDN if you need to) and therefore they all support the
QueryInterface method. This normally allows you to get from any one
interface a class supports to any other interface it supports.

From the info you sent me, I can't tell which class supports the
IUnitWrapper interface( that is indeed what it's called), but the
documentation you have should tell you. My guess would be CoUnitData,
so that's what I've used, but I could be wrong!

In Delphi, you can use the "as" operator to make a call to
QueryInterface.

By the way, don't call CoInitialize. In Delphi in a single threaded
app, this is normally not required. You have used OleServer (in the
type library import) which uses ComObj, and the latter calls
CoInitialize and CoUninitialize for you.

So, your code would read something like this:

procedure TForm1.Button1Click(Sender: TObject);
var
e : eciwrapper;
i : iUnitWrapper;
begin

try
begin
e := CoEciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000', 820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is a
subject ',
' 9 ', 0, ' ras1admin');

i := CoUnitData.Create as IUnitWrapper; // *

i.Dispatch('fs2000', 820, '1221', 'R234343433', 'Comment',
'Location', 'Mileage'); // Had to put some extra params here to
compile?

end;

except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;

end;


* - this could be replaced by:

if Succeeded(CoUnitData.Create.QueryInterface(IID_IUnitWrapper, i))
then
begin
i.Dispatch(.. etc..);
end
else
// Handle interface not supported

I just show this in case you have seen this form in examples.

Hope this gets you going.

Back to top
Aaron Miles
Guest





PostPosted: Fri Dec 03, 2004 11:41 am    Post subject: Re: How to use particular COM object Reply with quote

Hi John,

Thanks for the assistance

i := CoUnitData.Create as IUnitWrapper

and the alternative you provided gives me "Class Not Registered" error ... I
scan the registry and find the following key

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}]
@="IUnitWrapper"
[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}ProxyStu
bClsid]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}ProxyStu
bClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}TypeLib]
@="{50AC14A2-4C38-11D2-8670-0000F87A323C}"
"Version"="1.0"


Could this have something to do with it?

Once again thank you for the help you have provided to date. I know I/we
(ok .. more like 'you' Smile are getting closer.

Cheers,
Aaron

"John Carlyle-Clarke" <john.cc (AT) nospam (DOT) europlacer.co.uk> wrote

Quote:
"Aaron Miles" <miles3719(at)msn.com> wrote in
news:41afa8b8$1 (AT) newsgroups (DOT) borland.com:

I have found a few examples on the internet that refer to coClass
so I reimported the type library without the component wrapper
created so it more resembles the examples
so the code that I have at the moment is

var
e: eciwrapper;
i: iUnitWrapper;
begin
try
begin
coinitialize(nil);
e := coeciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000',820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is
a
subject', '9', 0, 'ras1admin');
i.Dispatch('fs2000',820',1221','R234343433'); <--- Failes
here with
Access Violation in Project1.exe Read of Address :000000000
end
except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;
end.


The problem is that I cannot find how to initialize the
iUnitWrapper interface (is that what its called?) so that I can
utilise its methods which I ultimatly want to use like dispatch,
enroute, arrive etc.. Thanks

OK, I understand the problem now. The type library you emailed me
contains these CoClasses:

CoECIWrapper, CoEventData, CoUnitData, CoCDConfig, CoCDConfigItem

Each of these has a default interface, but they also may support one
or more other interfaces. All COM interfaces derive from IUnknown
(look in the MSDN if you need to) and therefore they all support the
QueryInterface method. This normally allows you to get from any one
interface a class supports to any other interface it supports.

From the info you sent me, I can't tell which class supports the
IUnitWrapper interface( that is indeed what it's called), but the
documentation you have should tell you. My guess would be CoUnitData,
so that's what I've used, but I could be wrong!

In Delphi, you can use the "as" operator to make a call to
QueryInterface.

By the way, don't call CoInitialize. In Delphi in a single threaded
app, this is normally not required. You have used OleServer (in the
type library import) which uses ComObj, and the latter calls
CoInitialize and CoUninitialize for you.

So, your code would read something like this:

procedure TForm1.Button1Click(Sender: TObject);
var
e : eciwrapper;
i : iUnitWrapper;
begin

try
begin
e := CoEciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000', 820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is a
subject ',
' 9 ', 0, ' ras1admin');

i := CoUnitData.Create as IUnitWrapper; // *

i.Dispatch('fs2000', 820, '1221', 'R234343433', 'Comment',
'Location', 'Mileage'); // Had to put some extra params here to
compile?

end;

except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;

end;


* - this could be replaced by:

if Succeeded(CoUnitData.Create.QueryInterface(IID_IUnitWrapper, i))
then
begin
i.Dispatch(.. etc..);
end
else
// Handle interface not supported

I just show this in case you have seen this form in examples.

Hope this gets you going.



Back to top
Aaron Miles
Guest





PostPosted: Fri Dec 03, 2004 12:30 pm    Post subject: Re: How to use particular COM object Reply with quote

I just ended up trying all the coClasses and

i := coEciWrapper.Create as IUnitWrapper;

I am very happy at this point in time .. There will be more things to fix as
I move along I am sure !!!!

John .... you are a champion *pats on back*

The working code is

procedure TForm1.Button1Click(Sender: TObject);
var
e: eciwrapper;
i: iUnitWrapper;
begin
try
begin
e := CoEciwrapper.Create;
e.Initialise('disp', - 1, '');
e.SendMessageToTerminal('Sender', 820, 'From Code', 'This is a
subject', '9', 0, 'saints');
i := coEciWrapper.Create as IUnitWrapper;
i.LockUnit('saints',820,'1222');
i.Dispatch('saints', 820, '1222', 'R041602267', 'Comment', 'Location',
'Mileage');
sleep(2000);
i.Enroute('saints', 820, '1222', 'Enroute Location','Comments','');
sleep(2000);
i.Arrive('saints', 820, '1222', 'Arrive Location', 'Comment', '');
i.unLockUnit('saints',820,'1222');
end;
except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;
end;


Best Wishes,
Aaron Miles

"Aaron Miles" <miles3719(at)Msn.com> wrote

Quote:
Hi John,

Thanks for the assistance

i := CoUnitData.Create as IUnitWrapper

and the alternative you provided gives me "Class Not Registered" error ...
I
scan the registry and find the following key

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}]
@="IUnitWrapper"

[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}ProxyStu
bClsid]
@="{00020424-0000-0000-C000-000000000046}"

[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}ProxyStu
bClsid32]
@="{00020424-0000-0000-C000-000000000046}"

[HKEY_CLASSES_ROOTInterface{50AC14B1-4C38-11D2-8670-0000F87A323C}TypeLib]
@="{50AC14A2-4C38-11D2-8670-0000F87A323C}"
"Version"="1.0"


Could this have something to do with it?

Once again thank you for the help you have provided to date. I know I/we
(ok .. more like 'you' Smile are getting closer.

Cheers,
Aaron

"John Carlyle-Clarke" <john.cc (AT) nospam (DOT) europlacer.co.uk> wrote in message
news:Xns95B46205335D3johncceuroplacercouk (AT) 192 (DOT) 168.1.69...
"Aaron Miles" <miles3719(at)msn.com> wrote in
news:41afa8b8$1 (AT) newsgroups (DOT) borland.com:

I have found a few examples on the internet that refer to coClass
so I reimported the type library without the component wrapper
created so it more resembles the examples
so the code that I have at the moment is

var
e: eciwrapper;
i: iUnitWrapper;
begin
try
begin
coinitialize(nil);
e := coeciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000',820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is
a
subject', '9', 0, 'ras1admin');
i.Dispatch('fs2000',820',1221','R234343433'); <--- Failes
here with
Access Violation in Project1.exe Read of Address :000000000
end
except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;
end.


The problem is that I cannot find how to initialize the
iUnitWrapper interface (is that what its called?) so that I can
utilise its methods which I ultimatly want to use like dispatch,
enroute, arrive etc.. Thanks

OK, I understand the problem now. The type library you emailed me
contains these CoClasses:

CoECIWrapper, CoEventData, CoUnitData, CoCDConfig, CoCDConfigItem

Each of these has a default interface, but they also may support one
or more other interfaces. All COM interfaces derive from IUnknown
(look in the MSDN if you need to) and therefore they all support the
QueryInterface method. This normally allows you to get from any one
interface a class supports to any other interface it supports.

From the info you sent me, I can't tell which class supports the
IUnitWrapper interface( that is indeed what it's called), but the
documentation you have should tell you. My guess would be CoUnitData,
so that's what I've used, but I could be wrong!

In Delphi, you can use the "as" operator to make a call to
QueryInterface.

By the way, don't call CoInitialize. In Delphi in a single threaded
app, this is normally not required. You have used OleServer (in the
type library import) which uses ComObj, and the latter calls
CoInitialize and CoUninitialize for you.

So, your code would read something like this:

procedure TForm1.Button1Click(Sender: TObject);
var
e : eciwrapper;
i : iUnitWrapper;
begin

try
begin
e := CoEciwrapper.Create;
e.Initialise('disp', -1, '');
e.SetOperatorDetails('fs2000', 820);
e.SendMessageToTerminal('fs2000', 820, 'From Code', 'This is a
subject ',
' 9 ', 0, ' ras1admin');

i := CoUnitData.Create as IUnitWrapper; // *

i.Dispatch('fs2000', 820, '1221', 'R234343433', 'Comment',
'Location', 'Mileage'); // Had to put some extra params here to
compile?

end;

except
on e: Exception do
begin
writeln(e.ClassName);
writeln(e.message);
sleep(1000);
end;
end;

end;


* - this could be replaced by:

if Succeeded(CoUnitData.Create.QueryInterface(IID_IUnitWrapper, i))
then
begin
i.Dispatch(.. etc..);
end
else
// Handle interface not supported

I just show this in case you have seen this form in examples.

Hope this gets you going.





Back to top
John Carlyle-Clarke
Guest





PostPosted: Fri Dec 03, 2004 12:59 pm    Post subject: Re: How to use particular COM object Reply with quote

"Aaron Miles" <miles3719(at)Msn.com> wrote in
news:41b0510c (AT) newsgroups (DOT) borland.com:

Quote:
Hi John,

Thanks for the assistance

i := CoUnitData.Create as IUnitWrapper

and the alternative you provided gives me "Class Not Registered"
error ... I scan the registry and find the following key

I think this simply means that I guessed the wrong class :)

Try the code with CoECIWrapper, CoEventData, CoCDConfig, or
CoCDConfigItem instead of CoUnitData.

You could even write some code to test it, something like (untested):

var
I : IUnitWrapper;
begin

if Succeeded(CoUnitData.Create.QueryInterface(IID_IUnitWrapper, i))
then
Application.MessageBox('CoUnitData supports IUnitWrapper', 'Test',
MB_OK);

if Succeeded(CoECIWrapper.Create.QueryInterface(IID_IUnitWrapper, i))
then
Application.MessageBox('CoECIWrapper supports IUnitWrapper', 'Test',
MB_OK);

if Succeeded(CoEventData.Create.QueryInterface(IID_IUnitWrapper, i))
then
Application.MessageBox('CoEventData supports IUnitWrapper', 'Test',
MB_OK);

if Succeeded(CoCDConfig.Create.QueryInterface(IID_IUnitWrapper, i))
then
Application.MessageBox('CoCDConfig supports IUnitWrapper', 'Test',
MB_OK);

if Succeeded(CoCDConfigItem.Create.QueryInterface(IID_IUnitWrapper,
i))
then
Application.MessageBox('CoCDConfigItem supports IUnitWrapper',
'Test', MB_OK);

Back to top
John Carlyle-Clarke
Guest





PostPosted: Fri Dec 03, 2004 1:04 pm    Post subject: Re: How to use particular COM object Reply with quote

"Aaron Miles" <miles3719(at)Msn.com> wrote in
news:41b05c7a$1 (AT) newsgroups (DOT) borland.com:

Quote:
I just ended up trying all the coClasses and

i := coEciWrapper.Create as IUnitWrapper;

I am very happy at this point in time .. There will be more things
to fix as I move along I am sure !!!!

Glad it's working Smile You just beat me to it..

Quote:
The working code is

procedure TForm1.Button1Click(Sender: TObject);
var
e: eciwrapper;
i: iUnitWrapper;
begin

e := CoEciwrapper.Create;
{snip}


Quote:
i := coEciWrapper.Create as IUnitWrapper;

{snip}

Quote:
end;

That second line could just become i := e as IUnitWrapper;
in this case... Smile Why create two of them? It might even be
necessary to make it work..

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.