Click here to Skip to main content
15,909,742 members
Home / Discussions / COM
   

COM

 
GeneralRe: USES_CONVERSION Pin
Andrew Quinn AUS17-May-04 5:22
Andrew Quinn AUS17-May-04 5:22 
GeneralRe: USES_CONVERSION Pin
Roger Stoltz17-May-04 11:35
Roger Stoltz17-May-04 11:35 
GeneralRe: USES_CONVERSION Pin
Steve S17-May-04 23:26
Steve S17-May-04 23:26 
GeneralRe: USES_CONVERSION Pin
Roger Stoltz18-May-04 0:20
Roger Stoltz18-May-04 0:20 
GeneralRe: Thanks Everyone Pin
monrobot1320-May-04 6:49
monrobot1320-May-04 6:49 
GeneralWriting files simultaneously Pin
13-May-04 0:14
suss13-May-04 0:14 
GeneralInterface Methods Pin
monrobot1312-May-04 18:47
monrobot1312-May-04 18:47 
GeneralRe: Interface Methods Pin
Roger Stoltz12-May-04 22:14
Roger Stoltz12-May-04 22:14 
monrobot13 wrote:
Two questions:
One, can interface methods have default parameters? i.e.
HRESULT MyMethod ([in] int size = 0)


Yes. Have a look at the MIDL keywords 'optional' and defaultvalue' in MSDN.


Two, can a class that implements an interface have a constructor with paramaters?


Regarding the C++ synthax and if you mean whether it will compile or not, the answer is yes.
I don't see the use of it though. When the ClassFactory creates the object the default constructor will get called. It should be possible to modify the ClassFactory to call a constructor with parameters, but I don't know how much work that would be. I have a feeling that it would be much work for nothing since the same constructor will be called every time the object is created. Even if you take the long way of reading the registry by yourself to get the CLSID, calling CoGetClassObject and creating the object through the IClassFactory::CreateInstance method, there is no way you can pass parameters that can determine which constructor to call from the ClassFactory. Not through the COM-interfaces anyway. Technically you could have information elsewhere, e.g. in the registry, but I consider that an unstable solution and NOT recommendable.
Consider who is responsible for that kind of information; if it's you, you can reproduce that information in your default constructor and if your user is responsible you have no control of the information and that would require a lot of error checking and fault tolerant code. And if it doesn't work, you would still be the one the user blames. Eek! | :eek:

--
Roger
GeneralRe: Interface Methods Pin
monrobot1313-May-04 11:01
monrobot1313-May-04 11:01 
GeneralRe: Interface Methods Pin
Milton Karimbekallil12-May-04 23:13
Milton Karimbekallil12-May-04 23:13 
GeneralRe: Interface Methods Pin
monrobot1313-May-04 11:02
monrobot1313-May-04 11:02 
GeneralMFC application to DCOM Pin
paulkned12-May-04 4:32
paulkned12-May-04 4:32 
Generaldifference between MIDL Compiler Versions 6.00.0361 and 5.01.0164 Pin
Tarundeep Singh Kalra10-May-04 20:04
Tarundeep Singh Kalra10-May-04 20:04 
Generalhelp Pin
Member 93959610-May-04 0:07
Member 93959610-May-04 0:07 
GeneralRe: help Pin
Tuwing.Sabado8-Jun-04 17:37
Tuwing.Sabado8-Jun-04 17:37 
GeneralCustom Interface in COM Exe Pin
shahzi9-May-04 23:05
shahzi9-May-04 23:05 
GeneralRe: Custom Interface in COM Exe Pin
Mike Dimmick10-May-04 2:04
Mike Dimmick10-May-04 2:04 
GeneralBSTR Pin
monrobot139-May-04 13:48
monrobot139-May-04 13:48 
GeneralRe: BSTR Pin
Anonymous9-May-04 19:49
Anonymous9-May-04 19:49 
GeneralRe: BSTR Pin
monrobot1310-May-04 6:18
monrobot1310-May-04 6:18 
GeneralRe: BSTR Pin
Shaun Oldale11-May-04 2:55
Shaun Oldale11-May-04 2:55 
GeneralRe: BSTR Pin
monrobot1312-May-04 18:47
monrobot1312-May-04 18:47 
GeneralCOM+ Identity Pin
mtone7-May-04 7:46
mtone7-May-04 7:46 
GeneralRe: COM+ Identity Pin
Steve S7-May-04 8:29
Steve S7-May-04 8:29 
GeneralRe: COM+ Identity Pin
mtone7-May-04 9:08
mtone7-May-04 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.