开始我以为ole32.dll是一个COM,一直想引用,结果发现它只是一个函数库, 必须对它进行dllimport.具体代码可以看后面. 另外,我还发现以前微软的virsual studio 6 里面的Depends工具,依然在virsual studio 2005中提供了,目录在?:\Program Files\Microsoft Visual Studio 8\Common7\Tools 用这个工具可以查看一个函数库有哪些公开方法.
补充点知识,先
调用方法SetProperty
/**//*pls visit this article * * http://msdn2.microsoft.com/en-us/library/aa380328.aspx * To open an existing file, use the StgOpenStorageEx function instead. notice: Applications written for Windows 2000, Windows Server 2003 and Windows XP must use StgCreateStorageEx rather than StgCreateDocfile to take advantage of the enhanced Windows 2000 and Windows XP Structured Storage features. *
*/
using System; using System.Collections.Generic; using System.Text; using StructuredStorageWrapper;
namespace WindowsApplication8 { class FileSummary { publicstaticvoid SetProperty(string filename,string msg , SummaryPropId summaryType) { // first you need to either create or open a file and its // property set stream //申明接口(指针) IPropertySetStorage propSetStorage =null; //com 组件的 clsid 参见IPropertySetStorage定义 Guid IID_PropertySetStorage =new Guid("0000013A-0000-0000-C000-000000000046");
//Applications written for Windows 2000, Windows Server 2003 and Windows XP must use StgCreateStorageEx rather than StgCreateDocfile to take advantage of the enhanced Windows 2000 and Windows XP Structured Storage features uint hresult = ole32.StgOpenStorageEx( filename, (int)(STGM.SHARE_EXCLUSIVE | STGM.READWRITE), (int)STGFMT.FILE, 0, (IntPtr)0, (IntPtr)0, ref IID_PropertySetStorage, ref propSetStorage); //返回指针
// next you need to create or open the Summary Information property set Guid fmtid_SummaryProperties =new Guid("F29F85E0-4FF9-1068-AB91-08002B27B3D9"); IPropertyStorage propStorage =null;
// next, you assemble a property descriptor for the property you // want to write to, in our case the Comment property PropSpec propertySpecification =new PropSpec(); propertySpecification.ulKind =1; propertySpecification.Name_Or_ID =new IntPtr((int)summaryType);
//now, set the value you want in a property variant PropVariant propertyValue =new PropVariant(); propertyValue.FromObject(msg);
// Simply pass the property spec and its new value to the WriteMultiple // method and you're almost done propStorage.WriteMultiple(1, ref propertySpecification, ref propertyValue, 2);
// the only thing left to do is commit your changes. Now you're done! hresult = propStorage.Commit((int)STGC.DEFAULT);
用原型函数(prototype)可以定义一些很方便的自定义函数,实现各种自定义功能。本次主要是实现了Array的去重、获取最大值和最小值。
实现代码如下:
<script type="text/javascript">
Array.prototype.unique = function() {
var a = {};
var le
ORACLE
下面这个效率很低
SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT * FROM IPAY_RCD_FS_RETURN order by id desc) A ) WHERE RN <20;
下面这个效率很高
SELECT A.*, ROWNUM RN FROM (SELECT * FROM IPAY_RCD_
Reverse a singly linked list.
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
p