Creating COM objects?
- From: "Andrew Oborn" <v834@xxxxxxxxxxx>
- Date: Wed, 11 May 2005 14:42:12 +0100
Hi,
My knowledge of creating DLL's and COM objects in Delphi is next to zero,
but having read a few online tutorials I don't seem to be getting far,
hopefully someone can tell me if i'm doing something stupidly wrong..... I'm
just trying to start with something simple, pop up a messagebox and return a
value.
Im just trying to start by creating a simple COM object. In VB, I can just
create a new project, select active-x dll, rename the project and class,
then add a function thus:-
Public Function showmessage() As Integer
MsgBox "vb version of com object"
showmessage = 333
End Function
When I build the DLL and use from another language (in my case Visual Foxpro
cos you can do everything command line), it works perfectly, I see the
messagebox and get a value returned.
Now I try to do the same in delphi.........
I start by creating a new project, I've tried either DLL or active-x library
with the same results. After creating the project, I do file, new, COM
object. After giving it a name, I view the type library and add a method.
Editing the unit, I edit the method code and add:-
showmessage('Delphi version of com object');
result :=2222;
When I build and try to access, I can create the object, call the function,
I see the messagebox but no value is returned. I have also tried assigning a
value to the function name instead of result - no difference, I do not get
any return value..... Am I missing something here?
It seems that delphi is auto-generating a LOT of code in the unit and the
TLB file... is this really necessary? Am I selecting something I dont need,
bearing in mind the simplicity of the COM object?
Thanks in advance for any suggestions/pointers/e.t.c
Andrew
.
- Follow-Ups:
- Re: Creating COM objects?
- From: Marc Rohloff
- Re: Creating COM objects?
- From: J French
- Re: Creating COM objects?
- Prev by Date: Re: how to detect printer change?
- Next by Date: Resource File
- Previous by thread: how to detect printer change?
- Next by thread: Re: Creating COM objects?
- Index(es):
Relevant Pages
|