Click here to Skip to main content
15,914,163 members
Home / Discussions / COM
   

COM

 
QuestionError in ReleaseUMinSize build only Pin
itkid13-Oct-05 11:06
itkid13-Oct-05 11:06 
QuestionThe problem about Excel automation add-ins. Pin
dreamwinter12-Oct-05 20:49
dreamwinter12-Oct-05 20:49 
Question0x800401fb Pin
Joseph Hayes12-Oct-05 20:39
Joseph Hayes12-Oct-05 20:39 
AnswerRe: 0x800401fb Pin
Roger Stoltz12-Oct-05 20:59
Roger Stoltz12-Oct-05 20:59 
AnswerRe: 0x800401fb Pin
JonEngle26-Oct-05 18:39
JonEngle26-Oct-05 18:39 
QuestionIClassFactory::CreateInstance() Pin
odiesback12-Oct-05 6:50
odiesback12-Oct-05 6:50 
AnswerRe: IClassFactory::CreateInstance() Pin
User 21559712-Oct-05 11:57
User 21559712-Oct-05 11:57 
AnswerRe: IClassFactory::CreateInstance() Pin
rwestgraham12-Oct-05 12:38
rwestgraham12-Oct-05 12:38 
odiesback wrote:
IT COMPILES BUT IT CRASHES if I insist to use IClassFactory::CreateInstance...

Too complicated to go into. Smile | :) You need a good book on COM etc...
A better question is why do you not want to just use the first syntax???

odiesback wrote:
Then I replace it with

hr = CoCreateInstance(CLSID_CoCar, NULL, CLSCTX_INPROC_SERVER, IID_ICreateCar,
(void**)&pICreateCar);


This works because CoCreateInstance gets the factory for you behind the scenes, i.e.

CoCreateInstance first calls hr = CoGetClassObject(...factory parameters...)
Then it calls hr = pFactory->CreateInstance(...class parameters ...)

and returns the class pointer as hr.

The only real difference between the two approaches is convenience and performance.

When you call CoCreateInstance, COM gets the factory, and gets the class for you - it does all the work behind the scenes, and is convenient. But if you make multiple calls to get multiple instances of class from the same factory, COM may (or may not be, depending on a lot of things) recreating the same factory multiple times.

If you know in advance that you will be creating numerous instances of the same class objects from a specific factory, or if you know in advance that you will be creating different classes that are all supplied by a specific factory, then you can get the pointer to the factory yourself, hang on to it, and call pFactory->CreateInstance(...) directly.
GeneralRe: IClassFactory::CreateInstance() Pin
odiesback13-Oct-05 4:32
odiesback13-Oct-05 4:32 
AnswerRe: IClassFactory::CreateInstance() Pin
odiesback24-Oct-05 5:04
odiesback24-Oct-05 5:04 
QuestionActive Activex in the IDE Pin
lgaudouen11-Oct-05 7:21
lgaudouen11-Oct-05 7:21 
AnswerRe: Active Activex in the IDE Pin
vishalmore13-Oct-05 22:34
vishalmore13-Oct-05 22:34 
QuestionCreating only one instance Pin
ChemmieBro11-Oct-05 5:14
ChemmieBro11-Oct-05 5:14 
QuestionCreate a simple COM application Pin
Member 98603511-Oct-05 0:46
Member 98603511-Oct-05 0:46 
AnswerRe: Create a simple COM application Pin
dreamwinter19-Oct-05 22:26
dreamwinter19-Oct-05 22:26 
QuestionRetrive COM Interfaces Pin
benjamin2310-Oct-05 16:35
benjamin2310-Oct-05 16:35 
AnswerRe: Retrive COM Interfaces Pin
vishalmore11-Oct-05 1:54
vishalmore11-Oct-05 1:54 
AnswerRe: Retrive COM Interfaces Pin
User 21559711-Oct-05 8:37
User 21559711-Oct-05 8:37 
GeneralRe: Retrive COM Interfaces Pin
benjamin2311-Oct-05 16:53
benjamin2311-Oct-05 16:53 
GeneralRe: Retrive COM Interfaces Pin
User 21559711-Oct-05 21:03
User 21559711-Oct-05 21:03 
QuestionOPC Pin
Marc Soleda10-Oct-05 4:29
Marc Soleda10-Oct-05 4:29 
Questioninsert a object when the activex container Initializing Pin
ccto6-Oct-05 6:46
ccto6-Oct-05 6:46 
QuestionWebBrowserControl & DISPID_AMBIENT_DLCONTROL Pin
AlexR1236-Oct-05 6:28
AlexR1236-Oct-05 6:28 
QuestionSafeArrayCreate(Ex) Failure.... Pin
morenz6-Oct-05 2:46
morenz6-Oct-05 2:46 
AnswerRe: SafeArrayCreate(Ex) Failure.... Pin
David_Leikis6-Oct-05 5:17
David_Leikis6-Oct-05 5:17 

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.