COM component design and application (vi)--write the first component in ATL (vc.net)

Source: Internet
Author: User
Tags stub

First, the preface

1, with the "COM Component design and application (V)" content is basically consistent. But this is explained in Vc.net 2003 use method, even if you no longer use vc6.0, also please and the previous back of the content, reference comparison.

2, this first component, in addition to all COM components must be IUnknown interface, we implement a defined interface Ifun, it has two functions: Add () completes two numeric addition, Cat () completes two strings of the connection.

3, below ... Listen carefully! Here we go,:-).

Ii. establishment of the ATL project

Step 2.1: Create a solution.

Step 2.2: In this solution, create a new VC + + ATL project. The sample program is called Simple2, and the DLL is selected, as shown in figure I, figure ii.

Figure I, New ATL project

Figure II, select a non-attributed DLL component type

Attributed attribute programming is the direction of the future, but we should not choose it now.

dynamic-link library (DLL) select it.

Executable file (EXE) to speak later.

Service (EXE) represents the establishment of a system service component program that is loaded and executed after the system is started.

Allow the merge proxy/stub code to select the item to incorporate the proxy/stub code into the component program, otherwise compile separately and register the agent stub program separately. Agent/stub, what is this concept? Do you remember what we introduced in the last book? When callers invoke out-of-process or remote component functionality, the proxy/stub is responsible for data exchange. About the agent/stub of the specific changes and operations, and then again ...

Support MFC Unless there is a special reason, we write an ATL program, it is best not to select the item. You might say, if there is no MFC support, what about CString? Let me tell you a secret, I don't even tell him, I live on this secret for the rest of my life:

1, you can STL? Can be replaced by a string in STL;

2, oneself write a MyString class, hehe;

3, quietly, secretly, do not tell others (especially not to tell Microsoft), MFC in the CString source code to take over;

4, the use of CComBSTR class, at least can simplify our string operation;

5, directly with the API operation string, anyway, we all learn C language, is from here. (Equals did not say, hehe)

COM + features that support transaction processing for COM + 1.0 support. COM + may introduce it in the 99th time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.