?? csdn_文檔中心_在vc編寫的組件中使用asp對象.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0052)http://www.csdn.net/develop/Read_Article.asp?id=3524 -->
<!--內(nèi)容開始//--><HTML><HEAD><TITLE>CSDN_文檔中心_在VC編寫的組件中使用ASP對象</TITLE>
<META content="MSHTML 5.00.3315.2870" name=GENERATOR>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/csdn.css" rel=stylesheet></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<DIV align=center>
<STYLE>.title0 {
COLOR: #ffffff; FONT-FAMILY: arial; FONT-SIZE: 17px; FONT-WEIGHT: bold; TEXT-DECORATION: none
}
A.title2:link {
COLOR: #000000; TEXT-DECORATION: none
}
A.title2:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A.title2:active {
COLOR: #ff0000; TEXT-DECORATION: none
}
A.title2:hover {
COLOR: #ff0000; TEXT-DECORATION: none
}
</STYLE>
<SCRIPT language=JavaScript>
<!--
function submitlog(sign)
{
var types=document.alogon.type.options[document.alogon.type.selectedIndex].value;
if (document.alogon.name.value!="" && document.alogon.pass.value!="")
{
if (types!="1")
document.alogon.action="http://www.csdn.net/member/logon.asp";
else
document.alogon.action="http://expert.csdn.net/member/logon.asp";
if(sign)
document.alogon.submit();
//return true;
}
else
{
if (document.alogon.name.value=="")
alert("請輸入用戶名!");
if (document.alogon.pass.value=="")
alert("請輸入密碼");
return false;
}
return true;
}
function GetMyPass()
{
if (document.alogon.name.value!="")
{
document.alogon.action="http://www.csdn.net/member/getpass.asp";
document.alogon.submit();
}
else
{
alert("請在姓名輸入框里輸入用戶名或注冊EMAIL!");
}
}
// -->
</SCRIPT>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=770>
<TBODY>
<TR>
<TD bgColor=#004d99 height=25 width=20></TD>
<TD bgColor=#004d99> <A
href="http://www.csdn.net/member/login.asp"><FONT color=#ffff33>登
錄..</FONT></A> <A href="http://www.csdn.net/member/zc.asp"
target=_blank><FONT color=#ffff33>[注 冊]</FONT></A> <A
href="http://www.csdn.net/member/login.asp"><FONT
color=#ffff33>忘記密碼</FONT> </A> <A
href="http://www.csdn.net/member/logonout.asp"><FONT
color=#ffff33>注銷登錄</FONT> </A></TD>
<TD align=right bgColor=#990000 width=20><IMG height=25
src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/top_1.gif" width=20></TD>
<FORM action=http://www.csdn.net/search_ok.asp method=post target=_blank>
<TD align=right bgColor=#009999 width=250><FONT color=#ffffff><FONT
color=#ffffff><INPUT class=FormText_1 name=search size=15> <SELECT
class=FormText_1 name=type> <OPTION selected value=1>新聞標(biāo)題</OPTION>
<OPTION value=2>軟件名稱</OPTION> <OPTION value=3>商品名稱</OPTION> <OPTION
value=4>文檔標(biāo)題</OPTION> <OPTION value=6>職位名稱</OPTION></SELECT> </FONT><INPUT class=td3 name=Submit type=submit value="搜 索">
</FONT></TD></FORM></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=770>
<TBODY>
<TR>
<TD align=middle height=70 width=150><IMG height=60
src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/csdn.gif" width=120></TD>
<TD align=middle width=470>
<SCRIPT language=javascript>
var rand = Math.random().toString();
var ordval = parseInt(rand.substring(2,4));
function Showad(width)
{
if(width=='468')
{
document.write("<a href='http://www.dearbook.com.cn/' target='_blank'><OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' WIDTH=468 HEIGHT=60><PARAM NAME=movie VALUE='/adv//468x60.swf'> <PARAM NAME=quality VALUE=high> <EMBED src='/adv//468x60.swf' quality=high border=0 WIDTH=468 HEIGHT=60 TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED></OBJECT></a>");
return;
}
if(width=='120')
{
document.write("<a href='http://www.csdn.net/csdn/csdnClick.aspx?ad=Oracle-button1&adurl&adurl=http://www.oracle.com/global/cn/documentation/10g/index.html?content.html' target='_blank'><img src='/adv/develop/grid_computing_120x60_text1.gif' width=120 HEIGHT=60 border=0></a>");
return;
}
return;
}
Showad('468')</SCRIPT>
</TD>
<TD align=middle width=150>
<SCRIPT>Showad('120')</SCRIPT>
</TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=770>
<TBODY>
<TR>
<TD align=middle bgColor=#000000 colSpan=2 height=1 width=770></TD></TR>
<TR>
<TD align=middle bgColor=#004d99 height=28 width=150><FONT
class=title0>csdn.net</FONT></TD>
<TD align=middle width=620>
<SCRIPT src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/navigation1.js"></SCRIPT>
</TD></TR>
<TR>
<TD align=middle bgColor=#000000 colSpan=2 height=1
width=770></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=770>
<TBODY>
<TR>
<TD bgColor=#f3f9fc height=23 width=10></TD>
<TD bgColor=#f3f9fc>
<MARQUEE onmouseout=this.start() onmouseover=this.stop() scrollAmount=5
scrollDelay=80>
<SCRIPT src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/marquee.htm"></SCRIPT>
</MARQUEE></TD>
<TD align=right bgColor=#f3f9fc width=101>
<SCRIPT>document.write("<img src=http://count.csdn.net/count/pageview1.asp?columnid=4&itemid=11 border=0 width=0 height=0>");</SCRIPT>
<B>
<SCRIPT language=JavaScript>
<!--
document.ns = navigator.appName == "Netscape"
tmpDate = new Date();
date = tmpDate.getDate();
month= tmpDate.getMonth() + 1 ;
if(document.ns)
{
year1=tmpDate.getYear()
year= year1.toString().substr(1,2);
}
else
year= tmpDate.getYear();
document.write(year);
document.write(".");
document.write(month);
document.write(".");
document.write(date);
// -->
</SCRIPT>
</B> </TD></TR>
<TR bgColor=#999999>
<TD colSpan=3 height=1></TD></TR></TBODY></TABLE>
<TABLE border=0 width=770>
<TBODY>
<TR>
<TD align=middle bgColor=#fafafa class=td1 vAlign=top width=150><BR>
<SCRIPT src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/microsoft.js"></SCRIPT>
</TD>
<TD align=middle width=620>
<TABLE bgColor=#eeeeee border=0 cellPadding=0 cellSpacing=0 width=600>
<TBODY>
<TR bgColor=#ffffff>
<TD align=middle height=10 width=50></TD>
<TD align=right><A href="http://www.csdn.net/">CSDN</A> - <A
href="http://www.csdn.net/develop/">文檔中心</A> - <FONT
color=#003399>Visual C++</FONT> </TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR>
<TR>
<TD align=middle bgColor=#003399 height=10><FONT
color=#ffffff>標(biāo)題</FONT></TD>
<TD><B> 在VC編寫的組件中使用ASP對象</B> ghj1976(轉(zhuǎn)貼)
</TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR>
<TR>
<TD align=middle bgColor=#003399><FONT color=#ffffff>關(guān)鍵字</FONT></TD>
<TD width=500> 在VC編寫的組件中使用ASP對象</TD></TR>
<TR>
<TD align=middle height=5></TD>
<TD align=middle width=500></TD></TR>
<TR>
<TD align=middle bgColor=#003399 height=10><FONT
color=#ffffff>出處</FONT></TD>
<TD height=10> <A
href="http://home.kzinfo.net/getc/200101/20010116001.htm">http://home.kzinfo.net/getc/200101/20010116001.htm</A></TD></TR>
<TR>
<TD align=middle height=10></TD>
<TD height=10></TD></TR></TBODY></TABLE><!--文章說明信息結(jié)束//-->
<TABLE border=0 width=600>
<TBODY>
<TR>
<TD align=left><BR>
<TABLE align=left bgColor=#ffffff border=0 cellPadding=5
cellSpacing=0 height=400 width=608>
<TBODY>
<TR align=left vAlign=top>
<TD class=f1 height=30>
<P> </P></TD>
<TD class=f1 height=30> </TD></TR>
<TR align=middle vAlign=top>
<TD class=f1 colSpan=3 height=10></TD></TR>
<TR align=left vAlign=top>
<TD class=f1 width=6> </TD>
<TD class=f1 id=thetd width=565><!--jcstart-->討飯貓翻譯<BR><BR>簡介
<BR><BR>本文用一個簡單的sample演示如何在VC++
ATL編寫的組件中調(diào)用我們熟悉的ASP對象(Request,Response,Session等等)。你會發(fā)現(xiàn)在 Visual
C++中使用 ATL Object
Wizard就可以達(dá)到我們的目的。但使用OnStartPage,OnEndPage事件并不是最佳方法。
<BR><BR>在IIS3.0中,組件能通過IscriptingContext
接口存取ASP內(nèi)建對象,但這是通過頁面級方法來存取內(nèi)建對象。現(xiàn)在有了一種更好的實現(xiàn)方法,就是利用ObjectContext對象直接存取。ObjectContext使IIS應(yīng)用有更好的擴(kuò)展性,提供更完善的事務(wù)處理功能。強(qiáng)烈建議你把原有的應(yīng)用轉(zhuǎn)換到這種方式,但要求你的應(yīng)用支持事務(wù)處理。
<BR><BR>代碼
<BR><BR>首先需要包含一些必要的庫文件。我們需要mtx.h來定義一些常量,通過mtxas.dll得到IobjectContext接口,通過asp.dll得到ASP對象。
<BR><BR>#include <BR><BR>#import
"c:\Winnt\system32\mts\mtxas.dll" <BR><BR>#import
"c:\Winnt\system32\inetsrv\asp.dll"
<BR><BR><BR>然后,我們調(diào)入IobjectContext接口。
<BR><BR>MTxAS::ObjectContextPtr pObjectContext;
<BR><BR>HRESULT hr = GetObjectContext((IObjectContext**)
<BR><BR>&pObjectContext); <BR><BR><BR>下一步,通過context
對象得到我們需要的東西。這里舉兩個例子:session和response。 <BR><BR>//Session Object
<BR><BR>CComVariant v; <BR><BR>CComBSTR bstr(L"Session");
<BR><BR>CComQIPtr<BR><BR>(IGetContextProperties)>
pProps(pObjectContext); <BR><BR>hr =
pProps->GetProperty(bstr, &v); <BR><BR>CComPtr pDisp;
<BR><BR>pDisp = V_DISPATCH(&v);
<BR><BR>CComQIPtr<BR><BR>(ASPTypeLibrary::ISessionObject)>
pSession(pDisp); <BR><BR><BR><BR>//Response Object
<BR><BR>CComVariant v; <BR><BR>CComBSTR bstr(L"Response");
<BR><BR>CComQIPtr<BR><BR>(IGetContextProperties)>
pProps(pObjectContext); <BR><BR>hr =
pProps->GetProperty(bstr, &v); <BR><BR>CComPtr pDisp;
<BR><BR>pDisp = V_DISPATCH(&v);
<BR><BR>CComQIPtr<BR><BR>(ASPTypeLibrary::IResponse)>
pResponse(pDisp); <BR><BR><BR>最后來一個使用這個對象得簡單例子。
<BR><BR>//Retrieve a value from the Session Object.
<BR><BR>CComBSTR bstrVarName(L"TestSessionVar");
<BR><BR>VARIANT* pValue;
<BR><BR>pSession->get_Value(bstrVarName, pValue);
<BR><BR><BR>//Write that value out to the browser.
<BR><BR>pResponse->Write(pValue); <BR><BR><BR>總結(jié)
<BR><BR>雖然這只是一個很簡單的在VC++編寫的組件中調(diào)用ASP
內(nèi)建對象的例子,你可以按這個原理做更多的事情。Good luck。
<BR></TD></TR></TBODY></TABLE><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center bgColor=#006699 border=0 cellPadding=0 cellSpacing=0
width=770>
<TBODY>
<TR bgColor=#006699>
<TD align=middle bgColor=#006699 id=white><FONT
color=#ffffff>對該文的評論</FONT></TD>
<TD align=middle>
<SCRIPT src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/readnum.htm"></SCRIPT>
</TD></TR></TBODY></TABLE><BR>
<DIV align=center>
<TABLE align=center bgColor=#cccccc border=0 cellPadding=2 cellSpacing=1
width=770>
<TBODY>
<TR>
<TH bgColor=#006699 id=white><FONT
color=#ffffff>我要評論</FONT></TH></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 width=770>
<TBODY>
<TR>
<TD>你沒有登陸,無法發(fā)表評論。 請先<A
href="http://www.csdn.net/member/login.asp?from=/Develop/read_article.asp?id=3524">登陸</A>
<A
href="http://www.csdn.net/expert/zc.asp">我要注冊</A><BR></TD></TR></TBODY></TABLE></DIV><BR>
<HR noShade SIZE=1 width=770>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
<TBODY>
<TR align=middle>
<TD height=10 vAlign=bottom><A
href="http://www.csdn.net/intro/intro.asp?id=2">網(wǎng)站簡介</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=5">廣告服務(wù)</A> - <A
href="http://www.csdn.net/map/map.shtm">網(wǎng)站地圖</A> - <A
href="http://www.csdn.net/help/help.asp">幫助信息</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=2">聯(lián)系方式</A> - <A
href="http://www.csdn.net/english">English</A> </TD>
<TD align=middle rowSpan=3><A
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG
border=0 height=48 src="CSDN_文檔中心_在VC編寫的組件中使用ASP對象.files/biaoshi.gif"
width=40></A></TD></TR>
<TR align=middle>
<TD vAlign=top>百聯(lián)美達(dá)美公司 版權(quán)所有 京ICP證020026號</TD></TR>
<TR align=middle>
<TD vAlign=top><FONT face=Verdana>Copyright © CSDN.net, Inc. All rights
reserved</FONT></TD></TR>
<TR>
<TD height=15></TD>
<TD></TD></TR></TBODY></TABLE></DIV>
<DIV></DIV><!--內(nèi)容結(jié)束//--><!--結(jié)束//--></BODY></HTML>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -