Re: creating an ATL COM service
"Rohit Kumar" <RohitKumar@discussions.microsoft.com> wrote in message
news:C634354C-BC99-499B-9B99-6B587A3EFAFB@microsoft.com
When i am creating a new method, only the [in] checkbox is available
and the [out] & [ret] checkbox is greyed out. Dunno wats d problem.
I presume you know how to use a text editor.
Also as far as SubNumbers is considered, i am declaring a long
variable inside the function and then returning that long variable.
STDMETHODIMP CFirst_ATL::SubNumbers(LONG x, LONG y)
{
long abc;
[snip]
return abc;
}
You are supposed to return an HRESULT. HRESULT must be used as a
success/error code, not to report an actual result of the method.
Otherwise, if the call fails (e.g. the client is running on a different
machine and network is down, so the execution never even reaches your
method), it would be impossible to distinguish between an error code and
a legitimate result of an operation.
You should report the result the same way you do in AddNumbers, via
[out, retval] parameter.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925