Using the ATL COM AppWizard

来源:互联网 发布:怎样做到知敬畏守规矩 编辑:程序博客网 时间:2024/05/18 05:37
Using the ATL COM AppWizard

To create a project using the ATL COM AppWizard

  1. Open Visual C++. Click New on the File menu and click theProjects tab.

  2. Choose ATL COM AppWizard as your application type.

  3. Enter a project name.

  4. Click OK.

The ATL COM AppWizard displays a dialog box showing options that apply to your ATL project:

  • Choose from one of three server types: Dynamic Link Library (DLL) for an in-process server,Executable (EXE) for a local out-of-process server, or Service (EXE), which is a Windows NT application that runs in the background when NT starts up.

  • Select the Allow merging of proxy/stub code check box as a convenience when marshaling interfaces is required. This option places the MIDL generated proxy and stub code in the same DLL as the server.

  • Select the Support MFC check box (available for DLL projects only) to use MFC functionality (such asCString) in your server.

  • Select the Support MTS check box to modify the project build settings to support the Microsoft Transaction Server. For more information on adding MTS support to your project, seeMTS Support in ATL Projects.

Click Finish to generate the project. The AppWizard then displays information about the project that it is creating and then displays the newly created project in the Project Workspace.

Note   When you build your project, you can choose aMinSize or MinDependency configuration. MinSize will generate a smaller component, since shared code will be used from Atl.dll. In this case, you must distribute Atl.dll with your component.MinDependency will generate a larger component, since all necessary code will be linked in with your component.

Note   When building a Release version of a project, you can get the following link error:

LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main

This error occurs if you are using CRT functions that require CRT startup code. The Release configurations define_ATL_MIN_CRT, which excludes CRT startup code from your EXE or DLL. To avoid this error, do one of the following:

  • Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. On theProject menu, click Settings. In the Settings For: drop-down list, chooseMultiple Configurations. In the Select project configuration(s) to modify dialog box that appears, click the check boxes for all Release versions, and then clickOK. On the C/C++ tab, choose the General category, then remove_ATL_MIN_CRT from the Preprocessor definitions edit box.

  • If possible, remove calls to CRT functions that require CRT startup code and use their Win32 equivalents. For example, uselstrcmp instead of strcmp. Known functions that require CRT startup code are some of the string and floating point functions.
原创粉丝点击