Click here to Skip to main content
15,915,094 members
Home / Discussions / COM
   

COM

 
GeneralRe: returning array of BSTRs from the COM component Pin
Raj Prathap18-Jul-07 20:20
Raj Prathap18-Jul-07 20:20 
QuestionUnable to Start Exchange service Pin
Ashish Vasudev16-Jul-07 23:09
Ashish Vasudev16-Jul-07 23:09 
QuestionApartment (STA) mode before OLE calls Pin
MadmanWoo16-Jul-07 21:03
MadmanWoo16-Jul-07 21:03 
AnswerRe: Apartment (STA) mode before OLE calls Pin
User 21559716-Jul-07 22:58
User 21559716-Jul-07 22:58 
GeneralRe: Apartment (STA) mode before OLE calls Pin
MadmanWoo18-Jul-07 12:41
MadmanWoo18-Jul-07 12:41 
GeneralRe: Apartment (STA) mode before OLE calls Pin
User 21559719-Jul-07 19:44
User 21559719-Jul-07 19:44 
QuestionRegarding COM's Server type(DLL or EXE) Pin
Karismatic13-Jul-07 21:39
Karismatic13-Jul-07 21:39 
AnswerRe: Regarding COM's Server type(DLL or EXE) Pin
Mike Dimmick14-Jul-07 6:40
Mike Dimmick14-Jul-07 6:40 
DLL-based COM objects will load into the calling application's process. If you implement an EXE server, COM will start your EXE as a separate process. This should be transparent to the calling application. The main difference is that it will take much longer to call code running in another process than code running in your own process.

To actually call code in another process, or another apartment in the same process, COM must marshal the call parameters across the process or apartment boundary. This means writing out all the parameters, and any other areas of memory they reference, to some transport (e.g. a block of shared memory) and somehow signalling the other process that there is a call for it to handle. When the actual function returns, COM must then marshal the results back to the caller. To do this, it has to know the actual data types and whether a pointer represents a string, an array, or just a single object (and if a string or array, how long the string or array is), and whether the parameters are passed in only, passed out only or passed both in and out.

Marshalling can proceed in three ways:

1. The object implements the IMarshal interface;
2. A proxy/stub class is registered for the interface in the registry;
3. A type library is registered to use the Automation marshaller.

Option 3 is really a special case of option 2 - the Automation marshaller is registered as the proxy/stub class. It then looks up the correct type library and uses the information in that to perform the marshalling. This is the most limited option, however. You can only use the Automation data types and structures containing those types. The upside is that scripting languages like VBScript can use your components.

In general, for option 2, you don't actually write your own code for the proxy/stub class. Instead, you define your interfaces in IDL and pass them through the MIDL tool, which generates either tables describing the interfaces or code. The tables have been supported since Windows 98 and Windows NT 4.0, and an update is available for Windows 95 that supports them. All you have to do is build the code into a DLL; Visual Studio generates a project file for you.

COM gets the class factory object for a class implemented in a DLL by calling the DLL's DllGetClassObject function. It cannot call directly into an EXE's code, so the EXE must instead register its class factory objects, for classes that can be created externally, using the CoRegisterClassObject function.

EXE servers are mainly used for implementing OLE and Automation in desktop applications, and where isolation between the client and server is necessary (perhaps for security reasons). If the former, the application typically implements a command-line option (typically /embedding) to indicate that it was launched by COM, not by the user, and to hide its user interface in response.

Finally, it's possible to make a DLL server run in another process if it's registered as a COM+ Server Application. I'm not sure whether doing this with an arbitrary DLL is a good idea, it is probably best to use a component only how the author intended it to be used (as it is unlikely that they have tested other scenarios).

Stability. What an interesting concept. -- Chris Maunder

QuestionI am getting 'ICaptureGraphBuilder2' : missing storage-class or type specifiers Pin
yaminisridaran12-Jul-07 19:43
yaminisridaran12-Jul-07 19:43 
QuestionHow to Generate OLE dispatch map functions Pin
KASR111-Jul-07 23:01
KASR111-Jul-07 23:01 
Questionsugest me the basic COM book with C#.Net Pin
help as an alias11-Jul-07 19:00
help as an alias11-Jul-07 19:00 
AnswerRe: sugest me the basic COM book with C#.Net Pin
User 21559711-Jul-07 23:04
User 21559711-Jul-07 23:04 
QuestionThis problem is COM related Pin
beloveyyj9-Jul-07 23:03
beloveyyj9-Jul-07 23:03 
Questionir receiver Pin
Waqas Habib9-Jul-07 17:23
Waqas Habib9-Jul-07 17:23 
AnswerRe: ir receiver Pin
User 2155979-Jul-07 18:52
User 2155979-Jul-07 18:52 
QuestionShow Picture In ActiveX control Pin
eraccn8-Jul-07 19:34
eraccn8-Jul-07 19:34 
QuestionRetrieving the COM class factory for component with CLSID failed due to the following error: 80004005. Pin
kalaveer8-Jul-07 0:33
kalaveer8-Jul-07 0:33 
AnswerRe: Retrieving the COM class factory for component with CLSID failed due to the following error: 80004005. Pin
User 2155978-Jul-07 18:17
User 2155978-Jul-07 18:17 
AnswerRe: Retrieving the COM class factory for component with CLSID failed due to the following error: 80004005. Pin
MAW3021-Jul-07 20:42
MAW3021-Jul-07 20:42 
Questionplugin for Mozilla Pin
Dimkov6-Jul-07 6:31
Dimkov6-Jul-07 6:31 
AnswerRe: plugin for Mozilla Pin
User 2155978-Jul-07 18:19
User 2155978-Jul-07 18:19 
Questionwebservice Pin
brsecu6-Jul-07 3:39
brsecu6-Jul-07 3:39 
AnswerRe: webservice Pin
Thomas Chester9-Jul-07 8:04
Thomas Chester9-Jul-07 8:04 
Questionwhat should i do? Pin
eraccn5-Jul-07 17:30
eraccn5-Jul-07 17:30 
QuestionCall function in remote DLL Pin
Dimkov5-Jul-07 8:06
Dimkov5-Jul-07 8:06 

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.