Creating COM objects?



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


.



Relevant Pages

  • Re: Creating COM objects?
    ... >My knowledge of creating DLL's and COM objects in Delphi is next to zero, ... >When I build the DLL and use from another language (in my case Visual Foxpro ... >messagebox and get a value returned. ... Delphi exposes the true complexity ...
    (alt.comp.lang.borland-delphi)
  • Re: Using VB6 dll in Delphi app.
    ... to make a *windows standard* .dll with VB6. ... The trouble occurs when we try to use it in a Delphi app. ...
    (microsoft.public.vb.general.discussion)
  • Re: New Delphi roadmap is coming: NO UNICODE PLEASE!
    ... Avoids DLL hell, because it ... The app is deployed and the user is getting an error. ... instances where upgrading .NET broke things that were working. ... Coming from Delphi, this isn't any big deal of course. ...
    (borland.public.delphi.non-technical)
  • Re: DLL with string params callable via D4 and VB
    ... > I have a DLL written in D6 that uses ShortStrings as parameters. ... I can't get beyond Delphi to ... > Is there any guidance you could give in regards to passing string ... written in order to be used by EXCEL 97 VBA. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Why wont this work ?
    ... Yeap, more of a personal tool than a commercial offering, all of the other ... BHO tools i have found just dont seem to offer very much information, ... more about the dll, and hopefully will try and reveal what functions the ... Delphi IDE or RegSvr32 which brings us back in a full circle .... ...
    (alt.comp.lang.borland-delphi)