2
votes

I have to get the Command Interface and Status interface as given below from VBScript in an ASP Page. The COM will be deployed in a Windows CE device

Set polyColdObj=CreateObject("PolyCold.Main")
Set statusObj = polyColdObj.StatusInterface()
Set commandObj = polyColdObj.CommandInterface()

I am going to use Atl for developing the COM object. My doubts are

  1. What should be the signature of `StatusInterface` and `CommandInterface` in ATL COM?
  2. Should I call AddRef() on the `StatusInterface` and `CommandInterface` before returning the object to the automation client(VBScript)?
  3. Should I create the object each time StatusInterface is called or when 'PolyCold.Main' object is created?
  4. Is this the standard way of giving names for `StatusInterface` and `CommandInterface`?
1

1 Answers

2
votes

What should be the signature of StatusInterface and CommandInterface in ATL COM?

By default, ATL methods will return an HRESULT value. In order to achieve what you want you can create a method without parameters using the ATL wizard. Then you can modify your IDL file manually, and the corresponding implementation, so that your method returns an CommandInterface instead. Using this approach your IDL file will look like this:

[id(1)] CommandInterface* GetCommandInterface();

And the method declaration on your ATL class will be:

CommandInterface* GetCommandInterface();

Another option could be to use one output parammeter of type CommandInterface**. A quick test using the ATL wizard shows that your IDL file will look like this:

[id(1)] HRESULT StatusInterface([out] CommandInterface** outStatusInterface);

Should I call AddRef() on the StatusInterface and CommandInterface before returning the object to the automation client(VBScript)?

I would say yes, since VBScript/ASP is supposed to call Release() when your local variable goes out of scope.

Should I create the object each time StatusInterface is called or when 'PolyCold.Main' object is created?

This one is up to you. Only you know the details and needs of your design.

Is this the standard way of giving names for StatusInterface and CommandInterface?

If these "elements" are supposed to be interface types, then I would say no. In general interfaces are named with a capital I as first letter. I would use IStatus and ICommand for example. Probably with some more info saying what kind of command and status, but this is argumentative.