VC++ ATL/COM - Step 1 Creating COM Server DLL Component
1. Creating COM Server DLL Component
Open your Visual Studio 2005 editor and create a new project on Visual C++ and then select ATL Project.
Give the project name as SFTComServer. Click OK and move on to the next page. Then switch to Application Settings. For our example, the default settings would be perfect however you need to understand the difference between the options.
If the server type Dynamic Link Library, then your output would be a COM DLL component and will have an extension of .dll. And you need to use CLSCTX_INPROC_SERVER or CLSCTX_INPROC_HANDLER when you are creating your COM component from the client side.
If you have selected Executable (EXE), then output would be an application with .exe extension. And you need to use CLSCTX_LOCAL_SERVER when you are creating your COM component from the client side.
If you have selected the server type as Service and still the output would be an EXE and will act as a windows service.
The following is the screen shot of Application Settings.
- VC++ - Step 1 COM DLL Server Component
- VC++ - Step 2 Understanding ATL / COM Source Code Generated by Wizard
- VC++ - Step 2.1 MIDL Generated Files
- VC++ - Step 2.2 DLL Export Functions by COM DLL
- VC++ - Step 3 Adding a COM Interface
- VC++ - Step 3.1 Adding a COM Interface - Threading Model
- VC++ - Step 3.2 Adding a COM Interface - Aggregation
- VC++ - Step 3.3 Adding a COM Interface - Support
- VC++ - Step 3.4 Adding a COM Interface - Dual / Custom Interface
- VC++ - Step 4 Adding Methods to the interface
- VC++ - Step 5 COM Client Test Application in C++
- VC++ - Step 6 COM Client Test Application in C#
Click here to download the complete source code of COM DLL Server, C++ Client and CSharp Client
|