亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch12.htm

?? 用VC開發ACTIVEX書籍和隨書源碼
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--last modified on Tue, Apr 15, 1997 11:44 AM-->
<HTML>

<HEAD>
<!-- This document was created from RTF source by rtftohtml version 3.0.1 -->

	<META NAME="GENERATOR" Content="Symantec Visual Page 1.0">
	<META NAME="Author" Content="Steph Mineart">
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
	<TITLE>Chapter 12</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<H1>Chapter 12<BR>
Creating ActiveX COM Objects and Custom Interfaces Using MFC</H1>

<UL>
	<LI><A HREF="#Heading1">Creating ActiveX COM Objects and Custom Interfaces Using
	MFC</A>
	<UL>
		<LI><A HREF="#Heading2">Anatomy of a COM Object</A>
		<LI><A HREF="#Heading3">Tools Needed for Building COM Objects</A>
		<UL>
			<LI><A HREF="#Heading4">MIDL Compiler</A>
			<LI><A HREF="#Heading5">GUIDGEN</A>
			<LI><A HREF="#Heading6">RegEdit</A>
			<LI><A HREF="#Heading7">Registration Server</A>
			<LI><A HREF="#Heading8">Adding the Tools to the Visual C++ Development Environment</A>
		</UL>
		<LI><A HREF="#Heading9">Defining COM Interfaces Using IDL</A>
		<UL>
			<LI><A HREF="#Heading10">Creating the IFISH Project</A>
			<LI><A HREF="#Heading11">Creating the Interface Definition</A>
			<LI><A HREF="#Heading12">Listing 12.1 IFISH.IDL--Interface Definition for IFish</A>
			<LI><A HREF="#Heading13">Listing 12.2 IBASS.IDL--Interface Definition for IBass</A>
			<LI><A HREF="#Heading14">Compiling the Interface Definition Files</A>
			<LI><A HREF="#Heading15">Creating a Definition File</A>
			<LI><A HREF="#Heading16">Listing 12.3 DLL LIBRARY--Definition File for IFISH.DLL</A>
			<LI><A HREF="#Heading17">Adding the RPC Libraries to the Interface Project</A>
			<LI><A HREF="#Heading18">Listing 12.4 RPCHELP.C--Compiler Pragmas Used for Referencing
			RPC Libraries</A>
			<LI><A HREF="#Heading19">Registering the Interfaces</A>
			<LI><A HREF="#Heading20">Listing 12.5 IFISH.REG--Contexts of IFISH.REG File Used
			to Register the Interfaces Supported by the IFISH.DLL</A>
		</UL>
		<LI><A HREF="#Heading21">Implementing the Interface</A>
		<UL>
			<LI><A HREF="#Heading22">Using the Visual C++ AppWizard to Create the COM Object</A>
			<LI><A HREF="#Heading23">Accessing In-Process COM Objects</A>
			<LI><A HREF="#Heading24">Listing 12.6 BASS.DEF--BASS Definition File with the COM
			Support Functions Explicitly Exported</A>
			<LI><A HREF="#Heading25">Listing 12.7 BASS.CPP--DLlGetClassObject Implementation
			Code Inserted by the MFC AppWizard</A>
			<LI><A HREF="#Heading26">Listing 12.8 DLLCanUnloadNow--Implementation Code Inserted
			by the MFC AppWizard</A>
			<LI><A HREF="#Heading27">Listing 12.9 DllRegisterServer--Implementation Code Inserted
			by the MFC AppWizard</A>
			<LI><A HREF="#Heading28">Creating a Class that Implements COM Interfaces</A>
			<LI><A HREF="#Heading29">Listing 12.10 COMMACROS.H--COM Macros Used for Accessing
			the IUnknown Implementation of CCmdTarget</A>
			<LI><A HREF="#Heading30">Listing 12.11 BASSID.H--Header File bassid.h that Contains
			the Implementation of CLSID for the CBass Class</A>
			<LI><A HREF="#Heading31">Listing 12.12 BASS.H--Header File for the CBass Class (bass.h)</A>
			<LI><A HREF="#Heading32">Listing 12.13 BASS.CPP--Complete Implementation File for
			CBass object (Bass.cpp)</A>
		</UL>
		<LI><A HREF="#Heading33">Using the Interface</A>
		<UL>
			<LI><A HREF="#Heading34">OLE Initialization and Shutdown Functions</A>
			<LI><A HREF="#Heading35">Listing 12.14 COMTEST.CPP--Initialization and Removal of
			OLE Libraries within an MFC Application</A>
			<LI><A HREF="#Heading36">COM Object Access Functions</A>
			<LI><A HREF="#Heading37">Listing 12.15 Comtestview.cpp--Test Function Used for Accessing
			the IFish and IBass Interfaces</A>
		</UL>
		<LI><A HREF="#Heading38">From Here...</A>
	</UL>
</UL>

<P>
<HR SIZE="4">

<H1><A NAME="Heading1"></A>Creating ActiveX COM Objects and Custom Interfaces Using
MFC</H1>

<UL>
	<LI><B>Supporting COM with MFC</B> 
<SPACER TYPE="VERTICAL" SIZE="2">
 While MFC does not utilize COM directly, the MFC architects did provide support
	mechanisms that make adding COM functionality an easy task.
	<P>
	<LI><B>Adding COM tools to the Visual C++ development environment</B> 
<SPACER TYPE="VERTICAL" SIZE="2">
 The implementation of COM Objects requires new tools, such as the MIDL compiler,
	that are outside the scope of traditional application development.
	<P>
	<LI><B>Creating a basic Component Object using MFC</B> 
<SPACER TYPE="VERTICAL" SIZE="2">
 Examine the implementation and details of the two types of component objects, in-process
	(DLL) and out-of-process (EXE).
	<P>
	<LI><B>Defining a COM interface using the Interface Definition Language (IDL)</B>
	
<SPACER TYPE="VERTICAL" SIZE="2">
 The Interface Definition Language is used for defining your COM Object interface.
	<P>
	<LI><B>Setting up and installing COM Objects</B> 
<SPACER TYPE="VERTICAL" SIZE="2">
 Installing and using a COM Object is a straightforward process, but you need to
	be aware of a few trouble spots.
</UL>

<P>ActiveX is a strategic technology base for Internet programming and distributed
computing. While ActiveX is the successor for OLE (Object Linking and Embedding),
OLE still forms the foundation of ActiveX programming. The basis for ActiveX is to
provide an object-oriented solution for solving problems encountered in developing
operating systems and applications. ActiveX provides the specifications necessary
to create component software that ultimately benefits the computing industry.</P>
<P>At the core of ActiveX is an extremely powerful and extensible architecture called
the <I>Component Object Model (COM)</I>. COM provides a simple yet elegant solution
for solving complex software problems such as accessing objects and services outside
of application boundaries and version control. COM solves these problems through
the use of binary components that are running in the system rather than by developing
source code components within an application.</P>
<P>If you are using the Visual C++ compiler from Microsoft, chances are very high
that you are also using the Microsoft Foundation Classes (MFC) as the building blocks
for your applications and components. MFC is a powerful set of base classes that
provide a framework of abstractions into the Windows SDK for developing Win32 applications
and components.</P>
<P>Classes within the MFC framework are not directly derived from COM interfaces.
However, the architects of MFC have provided direct support for adding COM to any
MFC-based component or application. The roots for supporting COM within MFC lie in
wrappers called <I>Interface maps. </I>Interface maps are similar to message maps
(which are used for distributing Windows messages to MFC classes) in both concept
and execution.
<H2><A NAME="Heading2"></A>Anatomy of a COM Object</H2>
<P>COM Objects give software developers the ability to leverage object-oriented software
techniques for solving application and operating system development issues. The COM
specification is not geared toward a specific language, although C++ is a natural
choice when developing COM Objects. Four basic components compose a COM Object:

<UL>
	<LI>Classes--A <I>class</I> is a data structure with a set of interfaces used for
	accessing and manipulating the data structure. This definition is analogous to C++
	class. The difference is that COM allows a class created in any language to be registered
	with the operating system and to be used in a language-independent manner.
	<P>
	<LI>Objects--An <I>object</I> is an instance of a class created during program execution.
	In C++, an object is typically created via the <TT>new</TT> operator. When using
	COM, COM Objects are created through the function <TT>CoCreateInstance</TT>. Many
	instances of an object can be created.
	<P>
	<LI>Interfaces--An <I>interface </I>is a group of functions (often called methods)
	that are part of a class. The interface functions are used to directly manipulate
	the data in a class. ActiveX is based on a set of COM interfaces. Of the set of ActiveX
	interfaces, the two that must be supported by COM Objects are <TT>IUnknown</TT> and
	<TT>IClassFactory</TT>.
	<P>
	<LI>GUIDs--A GUID (Global Unique Identifier) is an 8-byte number that provides a
	unique identifier for each COM Object. <TT>GUID</TT>s are generated by a tool called
	<TT>GUIDGEN</TT>. Each COM class <I>must</I> have two <TT>GUID</TT>s, one for the
	Class ID and one for the Interface ID.
</UL>

<P>The <I>class ID </I>(<TT>CLSID</TT>) is an identifier for the COM class. This
key is registered in the Windows Registry and contains a pointer (path) to where
the DLL (Dynamic Link Library) or EXE containing the class can be located. The <TT>CLSID</TT>
can be found in the Windows Registry under the path HKEY_CLASSES_ROOT\CLSID.</P>
<P>The <I>Interface ID </I>(<TT>IID</TT>) is an identifier for the interface to the
class. The <TT>IID</TT> is used by applications to query and invoke the methods into
the class. The <TT>IID</TT> is also contained in the Windows Registry and can be
found in the path HKEY_CLASSES_ROOT\Interface. Figure 12.1 illustrates the relationship
among class, interfaces, and <TT>IID</TT>. <BR>
<BR>
<A HREF="Art/12/ifig01.jpg"><B>FIG. 12.1</B></A> <BR>
<I>Relationship of COM Classes and Interfaces.</I></P>
<P>What COM provides to software developers is an object-oriented solution for building
and maintaining software solutions. Programmers using non-object-oriented languages
such as Visual Basic can develop and use COM components to build software solutions.</P>
<P>COM also provides a unique solution to the version control problems present in
many of today's software solutions. Since COM Objects are binary components, developers
do not have to worry about new or updated versions of a component being placed on
a computer where their application is running. The reason for this is that COM deals
with interfaces. If an interface is enhanced, new methods can be added to the interface,
or additional interfaces can be obtained without breaking an existing application.
COM's solution to version control provides a great method for upgrading applications
while preserving legacy systems.
<H2><A NAME="Heading3"></A>Tools Needed for Building COM Objects</H2>
<P>When creating your COM Objects, a few tools must be installed on your computer.
Most of these tools are automatically installed as part of the Visual C++ development
environment.
<H3><A NAME="Heading4"></A>MIDL Compiler</H3>
<P>The Microsoft MIDL compiler is now a standard component of the Microsoft Visual
C++ environment. The MIDL compiler compiles COM interface definitions into C code,
which is then compiled into the project by the Visual C++ compiler. Figure 12.2 illustrates
the purpose of the MIDL compiler. <B><BR>
<BR>
</B><A HREF="Art/12/ifig02.jpg"><B>FIG. 12.2</B></A> <I><BR>
Inputs and outputs of the MIDL compiler.</I></P>
<P>The MIDL compiler also provides support for marshaling interfaces across process
boundaries. Starting with Visual C++ 4.0, the MIDL compiler was shipped as a standard
component of Visual C++. The MIDL compiler is also available with the Win32 SDK from
Microsoft.
<H3><A NAME="Heading5"></A>GUIDGEN</H3>
<P><TT>GUIDGEN</TT> is a tool used to generate Global Unique Identifiers (<TT>GUID</TT>),
which can be used for Interface IDs, Class IDs, or any other 128-bit <TT>UUID</TT>,
such as an <TT>RPC</TT> interface. <TT>GUIDGEN</TT> is installed when the OLE development
option is selected during the Visual C++ installation. When <TT>GUIDGEN</TT> is run,
you must select the proper format for the <TT>UUID</TT> and then press the New <TT>GUID</TT>
button to copy the <TT>UUID</TT> to the Windows Clipboard. After running the <TT>GUIDGEN</TT>
application, the resulting <TT>GUID</TT> is pasted from the Clipboard into the code
that needs a <TT>GUID</TT>. <BR>
<BR>
<IMG SRC="bar.gif" WIDTH="480" HEIGHT="6" ALIGN="BOTTOM" BORDER="0"></P>


<BLOCKQUOTE>
	<P><B>NOTE:</B> The tool <TT>GUIDGEN</TT> is also installed by default if the option
	Typical is selected during the Visual C++ 5.0 installation.

</BLOCKQUOTE>

<P><IMG SRC="bar.gif" WIDTH="480" HEIGHT="6" ALIGN="BOTTOM" BORDER="0">
<H3><A NAME="Heading6"></A>RegEdit</H3>
<P><TT>RegEdit</TT> or the registration editor is a standard component of both the
Windows 95 and Windows NT operating systems. The registration editor is used for
browsing and altering operating system and application settings. The registration
editor can also be used for installing and registering your COM Objects. <BR>
<BR>
<IMG SRC="bar.gif" WIDTH="480" HEIGHT="6" ALIGN="BOTTOM" BORDER="0"></P>


<BLOCKQUOTE>
	<P><B>CAUTION:<BR>
	</B><TT>RegEdit</TT> is a powerful tool and must be used with extreme caution by
	experienced users. If used improperly, systems can be damaged, resulting in a loss
	of data or a malfunctioning computer.

</BLOCKQUOTE>

<P><IMG SRC="bar.gif" WIDTH="480" HEIGHT="6" ALIGN="BOTTOM" BORDER="0"><BR>
<BR>
In Windows 95, this program is called regedit.exe. In Windows NT, this program is
called regedt32.exe.
<H3><A NAME="Heading7"></A>Registration Server</H3>
<P>The <I>registration server </I>is an application that can be used to register
the settings of a COM Object in the Windows registry without the need to create a
separate registration file. The application is called regsvr32.exe and is automatically
installed if the OLE development option is selected during Visual C++ installation

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产伦精品一区二区三区在线观看| 制服视频三区第一页精品| 国产成人在线视频网址| 久久精品久久综合| 精品一区二区免费| 国产精品自拍一区| 国产高清成人在线| 成人午夜电影久久影院| 丁香六月综合激情| 99视频国产精品| 色噜噜久久综合| 91国在线观看| 91精品国产综合久久精品app| 3atv在线一区二区三区| 精品国产一区久久| 中文字幕av免费专区久久| 国产精品日产欧美久久久久| 日韩毛片在线免费观看| 亚洲综合丝袜美腿| 婷婷成人综合网| 国产在线一区二区| 成人高清免费在线播放| 色婷婷国产精品| 欧美丰满高潮xxxx喷水动漫| 精品国产凹凸成av人导航| 久久午夜老司机| 亚洲天堂精品在线观看| 亚洲成av人在线观看| 激情综合网最新| 成人免费毛片片v| 日本高清成人免费播放| 日韩一区二区免费在线观看| 久久久亚洲高清| 亚洲精品成人悠悠色影视| 日韩在线观看一区二区| 国产一区二区视频在线| 91免费版在线看| 欧美一级二级三级乱码| 中文字幕巨乱亚洲| 亚洲国产另类精品专区| 国产乱码精品一区二区三区av| 91免费视频大全| 91麻豆精品久久久久蜜臀| 欧美激情一区二区三区四区 | 日韩成人午夜电影| 国产乱人伦偷精品视频免下载| 91小视频免费看| 91麻豆精品久久久久蜜臀| 国产无遮挡一区二区三区毛片日本| 亚洲最色的网站| 国产精品影视天天线| 欧美综合视频在线观看| 久久精品这里都是精品| 亚洲一区中文在线| 岛国精品在线播放| 7777精品久久久大香线蕉| 中文字幕的久久| 喷水一区二区三区| 91在线无精精品入口| 精品国产麻豆免费人成网站| 一区二区在线观看不卡| 精品中文av资源站在线观看| 色www精品视频在线观看| 2023国产精华国产精品| 五月婷婷综合在线| 99re这里都是精品| 欧美tickling挠脚心丨vk| 亚洲女同ⅹxx女同tv| 国产乱色国产精品免费视频| 欧美精品777| 一区二区三区丝袜| 成人av在线影院| 精品国产乱码久久久久久浪潮| 亚洲电影第三页| 91免费看片在线观看| 欧美激情一区二区三区四区| 另类小说一区二区三区| 欧美精品日韩一本| 亚洲精品日韩专区silk| 国产成人99久久亚洲综合精品| 日韩欧美亚洲另类制服综合在线| 亚洲一区二区成人在线观看| 99这里只有精品| 日本一区二区三级电影在线观看| 玖玖九九国产精品| 日韩欧美在线综合网| 午夜精品久久久久久久99樱桃| 91蜜桃在线观看| 日韩伦理av电影| 成人精品国产福利| 久久理论电影网| 国产麻豆日韩欧美久久| 欧美大片免费久久精品三p| 日欧美一区二区| 欧美日韩一级黄| 亚洲精品综合在线| 色婷婷精品大在线视频| 亚洲少妇屁股交4| caoporen国产精品视频| 国产精品久久久久一区二区三区 | 久久精品噜噜噜成人88aⅴ| 7777精品伊人久久久大香线蕉完整版 | 欧美一卡2卡三卡4卡5免费| 亚洲高清中文字幕| 欧美日韩综合一区| 亚洲成人tv网| 欧美日韩aaaaa| 日本v片在线高清不卡在线观看| 欧美日韩日日骚| 日本不卡不码高清免费观看| 日韩视频免费观看高清完整版 | 国产成人在线免费| 国产欧美日韩精品在线| 不卡大黄网站免费看| 中文字幕一区二区三区在线观看| 99久久er热在这里只有精品15 | 91麻豆免费看片| 一区二区三区四区亚洲| 欧美福利电影网| 精品在线视频一区| 欧美激情综合网| 91热门视频在线观看| 亚洲一线二线三线视频| 欧美一级在线视频| 国产一区二区三区在线观看免费视频 | 欧美一区二区在线不卡| 精彩视频一区二区| 中文一区二区在线观看| 91久久免费观看| 婷婷一区二区三区| 欧美精品一区二区三区一线天视频 | 国产精品77777竹菊影视小说| 国产精品美女久久久久高潮| 日本韩国欧美在线| 蜜桃av一区二区在线观看| 国产日韩欧美麻豆| 91免费在线视频观看| 日韩精品欧美精品| 久久人人97超碰com| 91美女视频网站| 日本中文一区二区三区| 久久久www成人免费毛片麻豆 | 91亚洲午夜精品久久久久久| 亚洲bt欧美bt精品| 久久免费美女视频| 色成人在线视频| 国产综合色在线| 亚洲宅男天堂在线观看无病毒| 日韩欧美高清在线| 91麻豆视频网站| 美国欧美日韩国产在线播放| 中文字幕免费在线观看视频一区| 精品视频免费在线| 高清不卡在线观看| 性做久久久久久久久| 久久久精品免费免费| 欧美日韩一区二区三区不卡| 国产精品亚洲人在线观看| 亚洲午夜久久久久久久久久久| 国产日韩欧美精品一区| 欧美日韩在线三区| 不卡大黄网站免费看| 久久不见久久见免费视频1| 亚洲天堂成人网| 精品国产123| 欧美无砖砖区免费| av影院午夜一区| 国产乱码精品1区2区3区| 香蕉av福利精品导航| 中文字幕一区二区三区不卡| 91麻豆精品国产| 在线观看区一区二| 懂色中文一区二区在线播放| 久久精品国产亚洲高清剧情介绍| 亚洲人吸女人奶水| 久久精品一区蜜桃臀影院| 欧美美女直播网站| 色呦呦一区二区三区| 国产成人激情av| 久久99国产精品久久99| 婷婷成人激情在线网| 一区二区三区在线观看网站| 日本一二三四高清不卡| 精品国产免费人成电影在线观看四季| 欧美色图激情小说| 一本一道久久a久久精品| 成人在线视频一区| 国产麻豆午夜三级精品| 蜜桃视频免费观看一区| 视频一区视频二区中文| 亚洲高清免费观看高清完整版在线观看| 国产精品久久久久aaaa| 国产性色一区二区| 久久夜色精品国产欧美乱极品| 91精品国产美女浴室洗澡无遮挡| 欧美日韩午夜在线视频| 欧美亚洲国产一区二区三区va | 久久久精品免费网站| 精品久久久久久久久久久院品网 | 欧美一区二区三区四区视频 |