.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);报错啊,提示代码不安全 --------------------编程问答--------------------
哦。no --------------------编程问答-------------------- --------------------编程问答-------------------- 高手在哪里
[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