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

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

?? ch04.htm

?? 用VC開發ACTIVEX書籍和隨書源碼
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<P><FONT COLOR="#0066FF"><TT><BR>
STDMETHODIMP CTracker::OutputLines(VARIANT * varOutputArray, <BR>
VARIANT varIndent, VARIANT_BOOL * RetVal) <BR>
{ <BR>
AFX_MANAGE_STATE(AfxGetStaticModuleState()) HRESULT hResult = S_OK; *RetVal = VARIANT_TRUE;
// if we have a file a if the variant contains a string array <BR>
if(m_fileLog &amp;&amp; varOutputArray-&gt;vt == (VT_ARRAY | VT_BSTR)) <BR>
{ <BR>
// lock the array so we can use it <BR>
if(::SafeArrayLock(varOutputArray-&gt;parray) == S_OK) <BR>
{ <BR>
LONG lLBound; // get the lower bound of the array <BR>
if(::SafeArrayGetLBound(varOutputArray-&gt;parray, 1, &amp;lLBound) == S_OK) <BR>
{ <BR>
LONG lUBound; // get the number of elements in the array <BR>
if(::SafeArrayGetUBound(varOutputArray-&gt;parray, 1, &amp;lUBound) <BR>
== S_OK) <BR>
{ <BR>
CString cstrIndent; <BR>
CTime oTimeStamp; <BR>
BSTR bstrTemp; // if we have an indent parameter <BR>
if(varIndent.vt != VT_I4) <BR>
{ <BR>
// get a variant that we can use <BR>
// for conversion purposes <BR>
VARIANT varConvertedValue; // initialize the variant <BR>
::VariantInit(&amp;varConvertedValue); // see if we can convert the data type to
something <BR>
// useful - VariantChangeTypeEx() could also be used <BR>
if(S_OK == ::VariantChangeType (&amp;varConvertedValue, <BR>
(VARIANT *) &amp;varIndent, 0, VT_I4)) <BR>
// assign the value to our member variable <BR>
m_lIndent = varConvertedValue.lVal; <BR>
} <BR>
else <BR>
// assign the value to our member variable m_lIndent = varIndent.lVal; // if we have
to indent the text <BR>
for(long lIndentCount = 0; lIndentCount &lt; m_lIndent; <BR>
lIndentCount++) <BR>
// add a tab to the string <BR>
cstrIndent += _T(&quot;\t&quot;); // for each of the elements in the array <BR>
for(long lArrayCount = lLBound; lArrayCount &lt; <BR>
(lUBound + lLBound); lArrayCount++) <BR>
{ <BR>
// update the time <BR>
oTimeStamp = CTime::GetCurrentTime(); <BR>
m_lHiResTime = timeGetTime(); // get the data from the array <BR>
if(::SafeArrayGetElement (varOutputArray-&gt;parray, <BR>
&amp;lArrayCount, &amp;bstrTemp) == S_OK) <BR>
{ <BR>
// output the data <BR>
fprintf(m_fileLog, _T(&quot;%s(%10ld)-%s%ls\n&quot;), <BR>
(LPCTSTR) oTimeStamp.Format (&quot;%H:%M:%S&quot;), <BR>
m_lHiResTime - m_lLastHiResTime, <BR>
(LPCTSTR) cstrIndent, bstrTemp); // store the last timer value <BR>
m_lLastHiResTime = m_lHiResTime; // free the bstr <BR>
::SysFreeString(bstrTemp); <BR>
} <BR>
} <BR>
} <BR>
else <BR>
{ <BR>
*RetVal = VARIANT_FALSE; // create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;Unable to retrieve the upper bound dimension of the array.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, <BR>
MFCSERVER_E_NO_UBOUND)); <BR>
} <BR>
} <BR>
else <BR>
{ <BR>
*RetVal = VARIANT_FALSE; // create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;Unable to retrieve the lower bound dimension of the array.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, <BR>
MFCSERVER_E_NO_LBOUND)); <BR>
} // unlock the array we don't need it anymore <BR>
::SafeArrayUnlock(varOutputArray-&gt;parray); <BR>
} <BR>
else <BR>
{ <BR>
*RetVal = VARIANT_FALSE; // create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;Unable to lock the array memory.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, <BR>
MFCSERVER_E_NO_ARRAYLOCK)); <BR>
} <BR>
} <BR>
else <BR>
{ <BR>
*RetVal = VARIANT_FALSE; // if there wasn't a file <BR>
if(!m_fileLog) <BR>
// create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;Invalid File Handle. File could not be opened for output.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, MFCSERVER_E_NO_FILE)); <BR>
else <BR>
// create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;The first parameter must be a string array passed by reference.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, <BR>
MFCSERVER_E_BAD_ARRAY_PARAMETER)); <BR>
} // return the result <BR>
return hResult; <BR>
} STDMETHODIMP CTracker::get_Indent(long * pVal) <BR>
{ <BR>
AFX_MANAGE_STATE(AfxGetStaticModuleState()) HRESULT hResult = S_OK; // return the
member variable <BR>
*pVal = m_lIndent; // return the result <BR>
return hResult; <BR>
} STDMETHODIMP CTracker::put_Indent(long newVal) <BR>
{ <BR>
AFX_MANAGE_STATE(AfxGetStaticModuleState()) HRESULT hResult = S_OK; // if the new
value is a least 0 <BR>
if(newVal &gt;= 0) <BR>
// assign the value to our member variable <BR>
m_lIndent = newVal; <BR>
else <BR>
{ <BR>
// create the error message <BR>
hResult = AtlReportError(CLSID_Tracker, <BR>
&quot;Invalid value. Value must be 0 or greater.&quot;, <BR>
IID_ITracker, <BR>
MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, MFCSERVER_E_INVALID_VALUE)); <BR>
} // return the result <BR>
return hResult; } </TT></FONT></P>
<P>The use of C++ exceptions is still permitted with an ATL-implemented server. But
the exception cannot cross application boundaries, which is the case in any application
whether implemented in MFC, ATL, or some other framework.
<H2><A NAME="Heading32"></A>Dual-Interface</H2>
<P>In <A HREF="ch03.htm">Chapter 3</A>, the basic MFC server is implemented as <TT>IDispatch</TT>
only. You are required to add dual-interface support as an extra step. With the ATL,
dual-interface support is built-in and implemented as a normal aspect of the server.
<H2><A NAME="Heading33"></A>Generating Dual-Interface OLE Exceptions</H2>
<P>Again, as in <A HREF="ch03.htm">Chapter 3</A>, the basic MFC server is implemented
as <TT>IDispatch</TT> only, and it is possible to throw standard C++ exceptions and
have the basic MFC <TT>IDispatch</TT> support code translate the error into an OLE
exception. When an MFC server is converted to dual-interface, you must implement
the exception translation code yourself.</P>
<P>For ATL, the server has been implemented as dual-interface from the start, and
all error generation has been written as true OLE exceptions and does not require
translation.
<H2><A NAME="Heading34"></A>Server Instantiation Using C++</H2>
<P>OLE is not the only method for creating and using Automation Servers. This chapter
will show you how to create OLE servers using C++ syntax.</P>
<P>At times, you must create and use Automation Servers from within the application
in which they are defined. Take, for example, a case where an application contains
three servers, with only one being directly creatable by outside applications using
OLE. The remaining two servers can be created by the exposed server using C++ and
returned via a method call to another application, which then uses the server as
though it was created via OLE.</P>
<P>For an MFC server, the inclusion or exclusion of the macros <TT>DECLARE_OLECREATE</TT>
and <TT>IMPLEMENT_OLECREATE</TT> determines whether a server is creatable by external
applications. For ATL, it is a little simpler. All ATL applications contain a global
variable called an <TT>ObjectMap</TT> for declaring all of the servers that can be
created via OLE. The <TT>ObjectMap</TT> is declared in the main application file
(see the file ATLServer.cpp) as a pair of macros:</P>
<P><FONT COLOR="#0066FF"><TT>BEGIN_OBJECT_MAP(ObjectMap)<BR>
END_OBJECT_MAP() </TT></FONT>Each OLE server implemented within the application will
have a single entry within the body of the <TT>ObjectMap</TT> macro, thus identifying
the server as an exposed OLE server. The <TT>OBJECT_ENTRY</TT> macro defines the
<TT>CLSID</TT> and the C++ class of the server that can be created.</P>
<PRE></PRE>
<P><FONT COLOR="#0066FF"><TT>BEGIN_OBJECT_MAP(ObjectMap) <BR>
OBJECT_ENTRY(CLSID_Tracker, CTracker) END_OBJECT_MAP() </TT></FONT></P>
<P>To prevent an application from being exposed as an Automation Server, you just
remove or comment out the entry in the object map. When adding additional servers
to an application, you must add an entry for each new server to the <TT>ObjectMap</TT>
macro.</P>
<P>All ATL servers contain a static function <TT>CreateInstance</TT>, which is used
to instantiate instances of themselves. You must use only the <TT>CreateInstance</TT>
function to instantiate a server since it is implemented by the class factory of
the server and will manage the server instantiation correctly. This is very critical
in the cases where the server is shared among two or more applications, as you will
see in the following sections.</P>
<P>The first step is to declare the pointer to which you will store the reference
of the object when it is created. Because ATL servers are implemented using templates,
it may seem a little strange to declare the reference this way. However, this makes
sense when you see the architecture of ATL, which is documented fully in the VC++
books online.</P>
<P><FONT COLOR="#0066FF"><TT><BR>
CComObject&lt;CTracker&gt; * opTracker; </TT></FONT></P>
<P>The next step is to instantiate the server and store the reference of the new
object. Remember to check the return value of the function and the pointer to ensure
that the object was instantiated successfully.</P>
<P><FONT COLOR="#0066FF"><TT><BR>
CComObject&lt;CTracker&gt;::CreateInstance(&amp;opTracker); </TT></FONT></P>
<P>Once a server is instantiated this way, you can use it like any other C++ class
or OLE server. You can use <TT>QueryInterface</TT> to retrieve <TT>IDispatch</TT>
or custom interface pointers that can be passed to other applications. Refer to <A
HREF="ch03.htm">Chapter 3</A> for more information regarding the instantiation and
use of OLE servers with C++.</P>
<P>So far, you've only looked at how to create individual instances of objects. In
the following section, you will learn how to share objects.
<H2><A NAME="Heading35"></A>Shared Servers</H2>
<P>OLE defines a facility for sharing objects called the <I>Running Object Table.
</I>Essentially, a shareable object will publish its <TT>CLSID</TT> and an <TT>IUnknown</TT>
reference to itself in the Running Object Table. Any application that so desires
can ask for the running instance of the object rather than create a new instance.
Applications that may need to work with a single running instance of an application
may find it more useful to use shared objects than to create multiple copies. The
<TT>Tracker</TT> object is a perfect candidate for this kind of functionality. Multiple
applications could use the same <TT>Tracker</TT> object to log information, thus
saving on memory.</P>
<P>Unfortunately, the way ATL is implemented prevents you from adding shared object
support without actually creating new ATL template classes. This limitation occurs
because of dependence on the <TT>Release</TT> function implementation to revoke the
object from the Running Object Table, which you cannot override directly in the base
ATL classes.</P>
<P>Listing 4.18 shows the support code that has been added to the StdAfx.h file to
support shared objects. The new classes and macros are based on the original ATL
code and have been extended to register the server in the Running Object Table. The
code will also remove the server from the Running Object Table when the reference
count reaches 1.</P>
<P>The only real change made to the original ATL code is that a new class <TT>CComObjectShared</TT>
is added with an extra template parameter of the <TT>CLSID</TT> of the server. The
remaining changes to the code and macros are to reflect the use of the new class
versus its original implementation <TT>CComObject</TT>. Do note that the shared server
implementation is simple and does not support aggregatable objects. But that is not
to say it cannot be implemented; it just wasn't done for this sample.</P>
<P>The constructor of the <TT>CComObjectShared</TT> class adds the <TT>IUnknown</TT>
reference to the Running Object Table and stores the ID in a member variable to be
used later when revoking the server.</P>
<P>The <TT>Release</TT> function is implemented the same as the MFC sample in that
the <TT>Release</TT> implementation revokes the server from the Running Object Table.
The code must also protect the <TT>Release</TT> call by bumping up the reference
count of the server and clearing the member variable to prevent recursion.
<H3><A NAME="Heading36"></A>Listing 4.18 STDAFX.H--Shared Object Support Classes
and Macros</H3>
<P><FONT COLOR="#0066FF"><TT><BR>
// ****** ATL 2.0 version - Added by Jerry Anderson for shared object support <BR>
// ** <BR>
#define DECLARE_NOT_AGGREGATABLE_SHARED(cBase, clsid) public:\ <BR>
typedef CComCreator2&lt; CComCreator&lt; CComObjectShared&lt;cBase, clsid&gt; &gt;,
CComFailCreator&lt;CLASS_E_NOAGGREGATION&gt; &gt; _CreatorClass; // if this object
was registered and the refcount is 1 (which is from the &quot;RegisterActiveObject&quot;)
<BR>
// then revoke the registration so the object can be destroyed properly - The AddRef/Release
pair <BR>
// is to protect the destruction and prevent the object from being deleted before
we are out of this call <BR>
// since the RevokeActiveObject is going to call &quot;Release&quot; also and the
refcount would be 0 if we didn

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品久久久久久久99水蜜桃| 国产毛片精品视频| 亚洲综合色噜噜狠狠| 麻豆91在线观看| 欧美专区在线观看一区| 久久综合成人精品亚洲另类欧美 | 国产福利一区二区三区视频| 国产一区二区三区免费观看| 91麻豆精品国产91| 一区二区三区**美女毛片| 国产精品白丝jk黑袜喷水| 欧美日韩综合在线| 日韩一级免费一区| 亚洲精品免费电影| 成人国产在线观看| 亚洲欧洲国产专区| 9久草视频在线视频精品| 国产精品福利一区二区三区| 国产做a爰片久久毛片| 久久久综合激的五月天| 99久久精品情趣| 日精品一区二区三区| 色婷婷精品久久二区二区蜜臂av| 一片黄亚洲嫩模| 精品国产人成亚洲区| 国产乱码精品一品二品| 国产精品久久夜| 欧美日韩国产大片| 国产中文一区二区三区| 91香蕉视频污| 麻豆视频观看网址久久| 一区二区三区四区不卡在线| 久久久综合精品| 精品1区2区3区| 93久久精品日日躁夜夜躁欧美| 免费日韩伦理电影| 一区二区三区精品在线观看| 成人亚洲一区二区一| 国产在线精品一区二区夜色| 亚洲欧美日韩久久| 久久久精品综合| 欧美日韩免费在线视频| 岛国一区二区在线观看| 久久精品国产999大香线蕉| 亚洲综合色噜噜狠狠| 亚洲人成在线播放网站岛国| 国产区在线观看成人精品| 91丨porny丨户外露出| 成人av电影在线观看| 国产传媒一区在线| 麻豆精品一区二区av白丝在线| 亚洲国产欧美日韩另类综合| 中文字幕久久午夜不卡| 久久久精品天堂| 日韩欧美中文字幕公布| 91九色最新地址| 在线一区二区视频| 91网站最新地址| 91精品办公室少妇高潮对白| av在线一区二区三区| 视频一区二区国产| 激情综合五月天| 成人精品免费网站| 成人美女视频在线看| www.欧美日韩| 欧美视频一二三区| 51久久夜色精品国产麻豆| 正在播放一区二区| 日韩欧美在线一区二区三区| 26uuu成人网一区二区三区| 国产欧美一区二区精品性色超碰| 色系网站成人免费| 国产91精品在线观看| 欧美午夜免费电影| 精品国产1区二区| 国产亚洲1区2区3区| 一区二区三区四区视频精品免费| 日韩黄色免费电影| 91在线小视频| 精品国产一区二区三区四区四 | 蜜桃久久av一区| 久久久亚洲午夜电影| 欧美日韩精品免费| 色综合色综合色综合色综合色综合 | 亚洲综合久久久| 丁香婷婷综合激情五月色| 午夜精品久久久久久久久| 国产亚洲欧美一级| 欧美男女性生活在线直播观看| 国产一区91精品张津瑜| 一区在线观看视频| 国产成人8x视频一区二区| 91视频com| 成人av网站在线观看| av中文字幕一区| 99视频在线观看一区三区| 91丨九色丨国产丨porny| 成人免费视频播放| 国产精品一二二区| 国产成人aaa| 欧美私人免费视频| 亚洲精品视频免费观看| 国产乱子伦视频一区二区三区| 91国内精品野花午夜精品| 日韩精品一区在线观看| 亚洲国产欧美日韩另类综合| 国产在线播放一区三区四| 在线不卡中文字幕播放| 国产日韩精品久久久| 色婷婷久久久亚洲一区二区三区| 欧美成人三级在线| 免费xxxx性欧美18vr| 欧美精品日韩综合在线| 亚洲第一主播视频| 91.麻豆视频| 激情图区综合网| 国产性做久久久久久| 国产一区三区三区| 欧美一区2区视频在线观看| 日韩精品乱码免费| 精品99一区二区| 麻豆久久一区二区| 2019国产精品| 色综合久久综合网欧美综合网 | 波多野结衣一区二区三区| 日本不卡123| 亚洲与欧洲av电影| ...av二区三区久久精品| 99国产精品久久久| 国产精品久久久久影院| 97久久精品人人澡人人爽| 日韩精品免费专区| 中文字幕一区二区日韩精品绯色 | 精品国产在天天线2019| 国产另类ts人妖一区二区| 夜夜爽夜夜爽精品视频| 国产欧美日韩视频一区二区| 欧美亚洲丝袜传媒另类| 成人中文字幕电影| 久久99精品国产麻豆不卡| 亚洲精品国产成人久久av盗摄 | 美女诱惑一区二区| 亚洲伦理在线免费看| 久久蜜桃av一区二区天堂| 欧美精品丝袜中出| 欧美日韩久久久一区| 99精品国产视频| hitomi一区二区三区精品| 久久成人羞羞网站| 久久国产尿小便嘘嘘尿| 日韩成人免费电影| 五月婷婷久久综合| 亚洲va国产天堂va久久en| 亚洲激情校园春色| 一区二区三区成人在线视频| 国产精品天干天干在线综合| 精品人在线二区三区| 欧美美女激情18p| 成人综合在线网站| 国产成人自拍网| 黑人精品欧美一区二区蜜桃| 一区二区三区日韩在线观看| 中文字幕一区二区三区不卡| 久久精品一二三| 亚洲欧洲成人av每日更新| 1000部国产精品成人观看| 亚洲欧洲综合另类在线| 亚洲国产一区二区三区| 午夜精品久久久久影视| 精品中文字幕一区二区| 成人美女视频在线观看18| 成人h精品动漫一区二区三区| 99久久精品国产观看| 欧美日韩一区二区三区在线看| 欧美精品国产精品| 日本一区二区在线不卡| 一区二区三区在线影院| 日本系列欧美系列| 99视频精品全部免费在线| 欧美日韩三级一区二区| 国产亚洲成av人在线观看导航| 成人欧美一区二区三区黑人麻豆| 中文字幕中文字幕一区| 日本va欧美va精品发布| fc2成人免费人成在线观看播放| 欧美三级三级三级爽爽爽| 精品国精品国产尤物美女| 一区二区三区在线播| 久久精品久久99精品久久| 欧美日韩电影在线播放| 亚洲少妇最新在线视频| 国产综合久久久久久鬼色| 欧美高清www午色夜在线视频| 亚洲国产成人午夜在线一区| 青青草精品视频| 欧美三级中文字| 国产精品久久国产精麻豆99网站| 日本在线观看不卡视频| 日本电影欧美片| 亚洲欧美在线高清|