⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 通过com技术实现windows外壳编程 - 果子专栏 - csdnblog.htm

📁 OPC document,collecting~
💻 HTM
📖 第 1 页 / 共 4 页
字号:
			        preProcessOut.OriginalText = control.innerHTML;				    control.innerHTML = textDuringCallBack;				}			}			control.disabled = (typeof enabledDuringCallBack == "undefined") ? false : !enabledDuringCallBack;			return true;        } else {            return false;        }	} else {	    if (callBackCancelledFunction) {		    callBackCancelledFunction(control);		}		return false;	}}function Anthem_PreProcessCallBackOut() {    // Fields    this.ParentElement = null;    this.OriginalText = '';    this.Enabled = true;}function Anthem_PostProcessCallBack(    result,     control,    eventTarget,     clientCallBack,     clientCallBackArg,     imageUrlDuringCallBack,     textDuringCallBack,     postCallBackFunction,     preProcessOut) {    if (postCallBackFunction) {        postCallBackFunction(control);    }	control.disabled = !preProcessOut.Enabled;    var inputType = control.getAttribute("type");    inputType = (inputType == null) ? '' : inputType.toUpperCase();	if (inputType == "IMAGE") {	    var form = document.getElementById(Anthem_FormID);        Anthem_RemoveHiddenInput(form, eventTarget + ".x");        Anthem_RemoveHiddenInput(form, eventTarget + ".y");	}	if (imageUrlDuringCallBack || textDuringCallBack) {	    if (control.nodeName.toUpperCase() == "INPUT") {	        if (inputType == "CHECKBOX" || inputType == "RADIO" || inputType == "TEXT") {	            SetLabelText(control.id, preProcessOut.OriginalText);	        } else if (inputType == "IMAGE") {	            if (imageUrlDuringCallBack) {	                control.src = preProcessOut.OriginalText;	            } else {	                preProcessOut.ParentElement.innerHTML = preProcessOut.OriginalText;	            }	        } else if (inputType == "SUBMIT") {	            control.value = preProcessOut.OriginalText;	        }	    } else if (control.nodeName.toUpperCase() == "SELECT") {	        SetLabelText(control.id, preProcessOut.OriginalText);	    } else {	        control.innerHTML = preProcessOut.OriginalText;	    }	}	if (clientCallBack) {	    clientCallBack(result, clientCallBackArg);	}}function Anthem_FireCallBackEvent(	control,	e,	eventTarget,	eventArgument,	causesValidation,	validationGroup,	imageUrlDuringCallBack,	textDuringCallBack,	enabledDuringCallBack,	preCallBackFunction,	postCallBackFunction,	callBackCancelledFunction,	includeControlValuesWithCallBack,	updatePageAfterCallBack) {	var preProcessOut = new Anthem_PreProcessCallBackOut();	var preProcessResult = Anthem_PreProcessCallBack(	    control, 	    e, 	    eventTarget,	    causesValidation, 	    validationGroup, 	    imageUrlDuringCallBack, 	    textDuringCallBack, 	    enabledDuringCallBack, 	    preCallBackFunction, 	    callBackCancelledFunction, 	    preProcessOut	);    if (preProcessResult) {	    Anthem_FireEvent(		    eventTarget,		    eventArgument,		    function(result) {                Anthem_PostProcessCallBack(                    result,                     control,                     eventTarget,                    null,                     null,                     imageUrlDuringCallBack,                     textDuringCallBack,                     postCallBackFunction,                     preProcessOut                );		    },		    null,		    includeControlValuesWithCallBack,		    updatePageAfterCallBack	    );    }}function AnthemListControl_OnClick(    e,	causesValidation,	validationGroup,	textDuringCallBack,	enabledDuringCallBack,	preCallBackFunction,	postCallBackFunction,	callBackCancelledFunction,	includeControlValuesWithCallBack,	updatePageAfterCallBack) {	var target = e.target || e.srcElement;	if (target.nodeName.toUpperCase() == "LABEL" && target.htmlFor != '')	    return;	var eventTarget = target.id.split("_").join("$");	Anthem_FireCallBackEvent(	    target, 	    e,	    eventTarget, 	    '', 	    causesValidation, 	    validationGroup, 	    '',	    textDuringCallBack, 	    enabledDuringCallBack, 	    preCallBackFunction, 	    postCallBackFunction, 	    callBackCancelledFunction, 	    true, 	    true	);}function GetLabelText(id) {    var labels = document.getElementsByTagName('label');    for (var i = 0; i < labels.length; i++) {        if (labels[i].htmlFor == id) {            return labels[i].innerHTML;        }    }    return null;}function SetLabelText(id, text) {    var labels = document.getElementsByTagName('label');    for (var i = 0; i < labels.length; i++) {        if (labels[i].htmlFor == id) {            labels[i].innerHTML = text;            return;        }    }}//]]></SCRIPT>

<SCRIPT src="通过COM技术实现Windows外壳编程 - 果子专栏 - CSDNBlog.files/WebResource.axd" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</SCRIPT>
 <!--done-->
<DIV id=banner>
<DIV id=bnr_pic><!--done-->
<DIV class=header>
<DIV class=headerText><A class=headermaintitle id=Header1_HeaderTitle 
href="http://blog.csdn.net/xgbing/">果子专栏</A><BR></DIV><BR>
<DIV class=headerDis></DIV></DIV></DIV></DIV>
<DIV id=main><!-- left starts -->
<DIV id=left>
<DIV id=mystats><BR><!--done-->
<DIV class=blogStats>原创 - 20, 翻译 - 0, 转贴 - 20, 点击 - 5014, 评论 - 2, Trackbacks -0 
</DIV></DIV>
<DIV id=mylinks><!--done--><!--done--><A class=mainmenu id=MyLinks1_csdnhome 
href="http://www.csdn.net/">CSDN首页</A>&nbsp;&nbsp;&nbsp; <A class=mainmenu 
id=MyLinks1_csdncommunity 
href="http://community.csdn.net/">CSDN社区</A>&nbsp;&nbsp;&nbsp; <A class=mainmenu 
id=MyLinks1_csdndev href="http://dev.csdn.net/">CSDN技术中心</A>&nbsp;&nbsp;&nbsp; 
<A class=mainmenu id=MyLinks1_HomeLink title=到聚合站点 
href="http://blog.csdn.net/">BLOG首页</A>&nbsp;&nbsp;&nbsp; <A class=mainmenu 
id=MyLinks1_PersonalHome title="访问 果子专栏" 
href="http://blog.csdn.net/xgbing/">我的首页</A>&nbsp;&nbsp;&nbsp; <A class=mainmenu 
id=MyLinks1_PersonalResume 
href="http://job.csdn.net/resumes/xgbing.aspx">个人档案</A>&nbsp;&nbsp;&nbsp; <A 
class=mainmenu id=MyLinks1_ContactLink 
href="http://blog.csdn.net/xgbing/contact.aspx">联系作者</A>&nbsp;&nbsp;&nbsp; <A 
class=mainmenu id=MyLinks1_Syndication 
href="http://blog.csdn.net/xgbing/Rss.aspx">聚合</A><A id=MyLinks1_XMLLink 
href="http://blog.csdn.net/xgbing/Rss.aspx"><IMG 
src="通过COM技术实现Windows外壳编程 - 果子专栏 - CSDNBlog.files/xml.gif" 
border=0></A>&nbsp;&nbsp;&nbsp; <A class=mainmenu id=MyLinks1_HyperLink1 
href="http://search.csdn.net/search_blog.asp" 
target=_blank>搜索</A>&nbsp;&nbsp;&nbsp; <A class=mainmenu id=MyLinks1_Admin 
href="http://writeblog.csdn.net/">登录</A></DIV>
<DIV id=topics>
<DIV class=Tag>
<SCRIPT language=javascript 
src="通过COM技术实现Windows外壳编程 - 果子专栏 - CSDNBlog.files/urltag.htm"></SCRIPT>

<DIV style="CLEAR: both"></DIV></DIV>
<SCRIPT>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</SCRIPT>

<DIV class=post>
<DIV class=postTitle><A 
href="http://blog.csdn.net/xgbing/articles/1236099.aspx"><IMG height=13 
src="通过COM技术实现Windows外壳编程 - 果子专栏 - CSDNBlog.files/zhuan.gif" width=15 
border=0>&nbsp;通过COM技术实现Windows外壳编程 </A></DIV>
<DIV 
class=postText><STRONG>摘要:</STRONG>本文介绍了一种有别于通常的Windows外壳编程方法。采用COM技术,通过Windows提供的外壳接口实现对其的编程。<BR><BR>  <STRONG><FONT 
color=#ac0000>一、 引言</FONT></STRONG><BR><BR>  在Windows环境下,不论是使用Visual 
C++还是Delphi或是其他一些软件开发工具,尽管存在着差别,但有一点是相同的:都是运行于Windows操作<A 
href="http://www.myfaq.com.cn/System/index.html" target=_blank>系统</A>之下的。在<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>开发过程中也经常要在自己的应用<A 
href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>中加入一些Windows<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>本身就有的功能,比如<A 
href="http://www.myfaq.com.cn/Soft/Tools/File/index.html" 
target=_blank>文件</A>的拷贝、删除、查找以及运行<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>等等。而这些功能在Windows操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>下都是具备的,显然如果能直接从<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>中调用这些功能将不仅仅减少<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>的大小和开发人员的工作量,而且由于是直接通过操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>来完成这些功能,将会大大减小这部分<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>出现异常错误的概率。Windows<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>虽说也存在不少错误,但常用功能的错误还是比较少的,而且通过补丁<A 
href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>可以更低限度减少<A 
href="http://www.myfaq.com.cn/System/index.html" target=_blank>系统</A>错误,因此<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>员可以将调试检错的注意力放在应用<A 
href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>的其他地方,对于调用<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>功能这部分代码则可以不必投入太大的精力去调试,因为这部分调试的工作在操作<A 
href="http://www.myfaq.com.cn/System/index.html" target=_blank>系统</A>发布的时候就已经由<A 
href="http://www.microsoft.com/" target=_blank>微软</A>做好了。<BR><BR>  <STRONG><FONT 
color=#ac0000>二、 Windows外壳编程</FONT></STRONG><BR><BR>  前面所说的直接使用Windows操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>部分功能的编程方法就是针对Windows操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>外壳的编程,可以通过对操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>提供的几个编程接口对操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>的部分功能进行调用,甚至可以按照自己的意图在应用<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>中对部分功能进行修改、扩展。但这方面的资料介绍不是特别多,讲的也大都语焉不详,而且用通常的编程方法去进行外壳编程是非常麻烦的,动辄就要对相关的结构对象进行设置,而这样的结构里的数据成员少则十来个多则几十个,因此配置起来非常烦琐,下面就以一个比较简单的外壳操作--拷贝<A 
href="http://www.myfaq.com.cn/Soft/Tools/File/index.html" 
target=_blank>文件</A>进行举例说明:<BR><BR>
<TABLE class=txcode cellSpacing=0 cellPadding=0 align=center border=0>
  <TBODY>
  <TR>
    <TD>……<BR>SHFILEOPSTRUCT FileOp; //外壳的<A 
      href="http://www.myfaq.com.cn/Soft/Tools/File/index.html" 
      target=_blank>文件</A>操作结构<BR>FileOp.hwnd=m_hWnd; 
      //设置句柄<BR>//设置操作方式,拷贝用FO_COPY,删除用 FO_DELETE<BR>FileOp.wFunc=FO_COPY; 
      <BR>FileOp.pFrom=m_source; //源<A 
      href="http://www.myfaq.com.cn/Soft/Tools/File/index.html" 
      target=_blank>文件</A>路径<BR>FileOp.pTo=m_detect; //目标<A 
      href="http://www.myfaq.com.cn/Soft/Tools/File/index.html" 
      target=_blank>文件</A>路径<BR>FileOp.fFlags=FOF_ALLOWUNDO; 
      //允许恢复<BR>FileOp.hNameMappings=NULL; 
      <BR>FileOp.lpszProgressTitle=strTitle; 
      //设置标题<BR>SHFileOperation(&amp;FileOp); 
      //执行外壳拷贝<BR>if(FileOp.fAnyOperationsAborted) //监测有无中止<BR>TRACE("An 
      Operation was 
aborted!!!\n");<BR>……</TD></TR></TBODY></TABLE><BR>  上述代码实现起来虽然效果还是不错的,但然实现起来却是比较麻烦的,这仅仅是一个比较简单的外壳操作,对于一些比较复杂的外壳操作比如<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>托盘、任务条等等的编程,更是尤为严重,而且象此类编程,MFC里并没有提供封装好的<A 
href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>类库,提供的只有<A 
href="http://www.myfaq.com.cn/System/index.html" target=_blank>系统</A>的WinAPI 
应用<A href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>接口,因此在<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>开发过程中往往会有一种在进行SDK编程的感觉。<BR><BR><BR><BR>  <STRONG><FONT 
color=#ac0000>三、 COM技术在Windows外壳编程中的应用</FONT></STRONG><BR><BR>  COM (Component 
Object Model,组件对象模型)是Microsoft创建的一种二进制和<A 
href="http://www.myfaq.com.cn/Net/index.html" 
target=_blank>网络</A>标准,也是Microsoft大力推广并已取得广泛认可的一种组件标准。在COM标准中,COM对象被很好的封装起来,客户无法访问对象的实现细节,提供给用户的唯一的访问途径是通过COM接口来访问。对于COM接口有两方面的含义:首先它是一组可供调用的函数,由此客户可以让该对象做某些事情;其次,也是更为重要的,接口是组件及其客户<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>之间的协议。也就是说接口不但定义了可用什么函数,也定义了当调用这些函数时对象要做什么。Windows操作<A 
href="http://www.myfaq.com.cn/System/index.html" 
target=_blank>系统</A>本身作为一个大的COM组件对象,也提供了一些必要的COM接口给客户<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>,因此我们可以通过这些COM接口来直接对Windows外壳进行编程。<BR><BR>  在<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>进行正式编写设计之前有一点是肯定的:<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>里需要用到COM接口,要对COM对象进行操作。因此首先要加入初始化COM和终止COM的代码。一般是在应用<A 
href="http://www.myfaq.com.cn/Dev/index.html" 
target=_blank>程序</A>类的InitInstance()函数的开始处和返回前添加初始化COM和终止COM代码的:<BR><BR>
<TABLE class=txcode cellSpacing=0 cellPadding=0 align=center border=0>
  <TBODY>
  <TR>
    <TD>……<BR>CoInitialize(NULL); //初始化COM<BR>……<BR>CoUninitialize(); 
      //终止COM代码<BR>……</TD></TR></TBODY></TABLE><BR>  以上两个函数在MFC<A 
href="http://www.myfaq.com.cn/Dev/index.html" target=_blank>程序</A>和非MFC<A 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -