当前位置:编程学习 > C#/ASP.NET >>

.net中实现IPersistStreamInt接口定义

[ComVisible(true), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713 " ) , InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 
public interface IPersistStreamInit  

 void GetClassID([In, Out] ref Guid pClassID);
 [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] 
 int IsDirty(); 
 void Load([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm); 
 void Save([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm,  
  [In, MarshalAs(UnmanagedType.I4)] int fClearDirty); 
 void GetSizeMax([Out, MarshalAs(UnmanagedType.LPArray)] long pcbSize); 
 void InitNew(); 



  IHTMLDocument2  Parse(string s)
  {
   IHTMLDocument2 pDocument=new HTMLDocumentClass();   
   if(pDocument!=null)
   {
    IPersistStreamInit pPersist=pDocument as IPersistStreamInit ;
    pPersist.InitNew();
    pPersist=null;
    IMarkupServices ms=pDocument as IMarkupServices ;
    if(ms!=null)
    {
     IMarkupContainer pMC=null;
     IMarkupPointer pStart,pEnd;
     ms.CreateMarkupPointer(out pStart);
     ms.CreateMarkupPointer(out pEnd);
     StringBuilder sb=new StringBuilder(s);  
     IntPtr pSource=Marshal.StringToHGlobalUni(s);
     ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);
     if(pMC!=null)
     {
      Marshal.Release(pSource);
      return pMC as IHTMLDocument2;
     }
     Marshal.Release(pSource);
    }
   }
   return null;
  }


ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);报错啊,提示代码不安全 --------------------编程问答--------------------
引用 楼主 u013213478 的回复:
[ComVisible(true), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713 " ) , InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 
public interface IPersistStreamInit  

 void GetClassID([In, Out] ref Guid pClassID);
 [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] 
 int IsDirty(); 
 void Load([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm); 
 void Save([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm,  
  [In, MarshalAs(UnmanagedType.I4)] int fClearDirty); 
 void GetSizeMax([Out, MarshalAs(UnmanagedType.LPArray)] long pcbSize); 
 void InitNew(); 



  IHTMLDocument2  Parse(string s)
  {
   IHTMLDocument2 pDocument=new HTMLDocumentClass();   
   if(pDocument!=null)
   {
    IPersistStreamInit pPersist=pDocument as IPersistStreamInit ;
    pPersist.InitNew();
    pPersist=null;
    IMarkupServices ms=pDocument as IMarkupServices ;
    if(ms!=null)
    {
     IMarkupContainer pMC=null;
     IMarkupPointer pStart,pEnd;
     ms.CreateMarkupPointer(out pStart);
     ms.CreateMarkupPointer(out pEnd);
     StringBuilder sb=new StringBuilder(s);  
     IntPtr pSource=Marshal.StringToHGlobalUni(s);
     ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);
     if(pMC!=null)
     {
      Marshal.Release(pSource);
      return pMC as IHTMLDocument2;
     }
     Marshal.Release(pSource);
    }
   }
   return null;
  }


ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);报错啊,提示代码不安全


哦。no --------------------编程问答--------------------
引用 1 楼 hou306010849 的回复:
Quote: 引用 楼主 u013213478 的回复:

[ComVisible(true), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713 " ) , InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 
public interface IPersistStreamInit  

 void GetClassID([In, Out] ref Guid pClassID);
 [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] 
 int IsDirty(); 
 void Load([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm); 
 void Save([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm,  
  [In, MarshalAs(UnmanagedType.I4)] int fClearDirty); 
 void GetSizeMax([Out, MarshalAs(UnmanagedType.LPArray)] long pcbSize); 
 void InitNew(); 



  IHTMLDocument2  Parse(string s)
  {
   IHTMLDocument2 pDocument=new HTMLDocumentClass();   
   if(pDocument!=null)
   {
    IPersistStreamInit pPersist=pDocument as IPersistStreamInit ;
    pPersist.InitNew();
    pPersist=null;
    IMarkupServices ms=pDocument as IMarkupServices ;
    if(ms!=null)
    {
     IMarkupContainer pMC=null;
     IMarkupPointer pStart,pEnd;
     ms.CreateMarkupPointer(out pStart);
     ms.CreateMarkupPointer(out pEnd);
     StringBuilder sb=new StringBuilder(s);  
     IntPtr pSource=Marshal.StringToHGlobalUni(s);
     ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);
     if(pMC!=null)
     {
      Marshal.Release(pSource);
      return pMC as IHTMLDocument2;
     }
     Marshal.Release(pSource);
    }
   }
   return null;
  }


ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);报错啊,提示代码不安全


哦。no
--------------------编程问答-------------------- 高手在哪里
引用 2 楼 u013213478 的回复:
Quote: 引用 1 楼 hou306010849 的回复:

Quote: 引用 楼主 u013213478 的回复:

[ComVisible(true), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713 " ) , InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 
public interface IPersistStreamInit  

 void GetClassID([In, Out] ref Guid pClassID);
 [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] 
 int IsDirty(); 
 void Load([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm); 
 void Save([In, MarshalAs(UnmanagedType.Interface)] UCOMIStream pstm,  
  [In, MarshalAs(UnmanagedType.I4)] int fClearDirty); 
 void GetSizeMax([Out, MarshalAs(UnmanagedType.LPArray)] long pcbSize); 
 void InitNew(); 



  IHTMLDocument2  Parse(string s)
  {
   IHTMLDocument2 pDocument=new HTMLDocumentClass();   
   if(pDocument!=null)
   {
    IPersistStreamInit pPersist=pDocument as IPersistStreamInit ;
    pPersist.InitNew();
    pPersist=null;
    IMarkupServices ms=pDocument as IMarkupServices ;
    if(ms!=null)
    {
     IMarkupContainer pMC=null;
     IMarkupPointer pStart,pEnd;
     ms.CreateMarkupPointer(out pStart);
     ms.CreateMarkupPointer(out pEnd);
     StringBuilder sb=new StringBuilder(s);  
     IntPtr pSource=Marshal.StringToHGlobalUni(s);
     ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);
     if(pMC!=null)
     {
      Marshal.Release(pSource);
      return pMC as IHTMLDocument2;
     }
     Marshal.Release(pSource);
    }
   }
   return null;
  }


ms.ParseString(ref *(ushort*)pSource.ToPointer(),0,out pMC,pStart,pEnd);报错啊,提示代码不安全


哦。no
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,