Simple example of developing and deploying ActiveX controls with ATL

Source: Internet
Author: User
Tags header win32

Write an ATL component, add a simple class, and add in the class header file:BEGIN_CATEGORY_MAP(CAirlineInfo)
IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
END_CATEGORY_MAP()

The header file (#include <objsafe.h>) required by the above code is then introduced to stdafx.h. Then in the class casually add a method call WinExec () function OK, see zqcom Engineering.

Publishing on the web requires that the dependent files be packaged as. cab, which includes the Dll,dll dependent libraries and an INF file for the component. The contents of the INF file in my example are as follows:

[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
zqcom.dll=zqcom.dll
msvcr71d.dll=msvcr71d.dll
[zqcom.dll]
file-win32-x86=thiscab
clsid={CB4C551D-2BF5-40F7-866B-922DBEA618F2}
FileVersion=1,0,0,0
RegisterServer=yes
[msvcr71d.dll]
file-win32-x86=thiscab
RegisterServer=yes

The contents of [version] are fixed, [Add.Code] is for the content to be added, Zqcom.dll is the component to be added, Msvcr71d.dll is a dependent library of Zqcom.dll, (I'm using. NET, so it's msvcr71d.dll, if the vc6.0 is Mfc42.dll), [Zqcom.dll] is some information, and the CLSID corresponds to the CLSID of the class.

Note: Because the component is not signed, the client accesses the security settings, and the Internet and intranet settings are changed to allow unsigned ActiveX components to run in property security, and should be back after installation.

How to package. cab:

At the command line, enter:

CABARC n e:\myinf.cab e:\zqcom.dll e:\msvcr71d.dll e:\test.inf

Place the generated. cab in the corresponding position, and my cab is placed under: c:\Inetpub\wwwroot\. If the CABARC is not running, then search the machine, then add the environment path, all OK.

This article supporting source code

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.