Complex Parameter with Gupta-COM

With the Gupta Team Developer you can create COM objects so that you can use the functionality in other languages such as C# ­. How this works is described in this article .

So far I had always used the generic data types String, DateTime and Number in COM functions as a return value or parameter. Receive parameters are also possible and necessary if you want to pass e.g. a data set. However, the parameter lists of COM functions are often long and unwieldy. Maintaining, expanding and using these functions is cumbersome and error-prone. The wish to be able to pass complex parameters – as classes and their member variables – was getting bigger. Fortunately, the Gupta IDE offers a solution: you can create another COM object, define the required data elements as properties, and then use it as a function parameter in a COM function.

Properties in COM-Objects

Using the COM-Wizard (component / wizards / COM class) create a CoClass named „ComplexParameter“.


In the next step the properties are added. In my example each one for the data types of String, DateTime and Number. I chose  „Set/Get“ in the section „Declaration“. Looking at the program code generated by the wizard you can see what it’s all about.


The code generated by the wizard is remarkable: For each property, an Instance Variable m_PropertyName has been created as well as two functions named PropSetPropertyName and PropGetPropertyName.


Referencing the COM object e.g. in a Visual Studio project, the properties appear again as thought: as ordinary member variables of the object. You can’t see the ‚ PropSet/PropGet ‚ functions. Those were automatically identified as „Setters“ and „Getters“ and will be used from the .NET Framework as such. They are called implicitly when assigning or setting the property value.

Information about the concept for Getters und Setters can be found here


Sample Functions

To complete the example I create yet a COM service class with two functions which use the above generated COM data object as a parameter. In the GetSampleComplexParameter(..) function it is passed as return value and in the function SaveComplexParameter(..) the COM data object is used as a function parameter. Please note following rule which is not documented anywhere but is crucial for the functioning of the COM object: If you use a COM object as a return value or Parameter you have to use the Interface of the COM object in the declaration of the return value or parameter. Use the COM class, which is initiated with the „I“. But when you „work“ with COM dataobject – as a „local variable“ or „static variable“ – use the COM class without the leading „I“. This is evident in the program code of the function „GetSampleComplexParameter“ below: the return value is of the type IComplexParameter. The local variable that is returned is of type ComplexParameter. If you don’t consider this rule you will get errors when using COM object.



To demonstrate the functionality, I wrote a WinForm application called „UsingComComplexParameters“ in C#  which integrates the Gupta-COM object and calls its two service functions.



The zip file contains the full demo with source files:

The zip file contains the full demo including source files:

  • The Gupta-Project „ComComplexParameter“,
  • the WinForm-Application „UsingComComplexParameter“
  • as well as a working demo „WorkingDemo“ with a batch script  „InstallAndRunComComplexParameterDemo.bat“ which registers the COM object, calls the WinForm app and cleans up afterwards.


Happy coding.


Über thomasuttendorfer
Ich bin Entwicklungsleiter bei der Softwarefirma [ frevel & fey ] in München. Wir entwickeln Business-Software für Verlage und verwenden dafür den Gupta Team-Developer sowie Visual Studio.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )


Verbinde mit %s

%d Bloggern gefällt das: