This example describes the method of initializing COM components in C + +. Share to everyone for your reference. Specifically as follows:
Use BCB here
Initialization is required when using components such as Tadoconnect
Call Interface:
?
1 2 |
CoInitialize (NULL);//Initialize COM suite couninitialize ();//Free COM Suite |
Called in the DLL Portal:
?
1 2 3 4, 5 6 7 8 9 10 11 12 13 14 15 |
static bool Iscoinitialize = FALSE; is the initialization int WINAPI DllEntryPoint (hinstance hinst, unsigned long reason, void* lpreserved) {if (Reason==dll_process_ ATTACH) {if (coninitialize (NULL) = S_OK) Iscoinitialize = true;} if (Reason==dll_process_detach) {if (iscoinitialize) cou Ninitialize (); is released by its own initialization, otherwise it is freed by other initialization,//prevents the wrong release from causing the other caller to fail} return 1; } |
I hope this article will help you with the C + + program design.