c#获取com对象的progid

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace ImportExcelBill
{
    [InterfaceType(1)]
    [Guid("0000010C-0000-0000-C000-000000000046")]
    public interface IPersist
    {
        void GetClassID(out Guid pClassID);
    }

    public class ICMOList
    {
        [DllImport("ole32.dll")]
        static extern int ProgIDFromCLSID([In] ref Guid clsid, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgID);
        public void MainFunction(String sKey  , Object oList , Boolean bCancel  )
        {
            string progId = "";
            IPersist persist = oList as IPersist;
            if (persist != null)
            {
                Guid classId;
                persist.GetClassID(out classId);
               
                ProgIDFromCLSID(ref classId, out progId);
            }
            Marshal.ReleaseComObject(oList);


            MessageBox.Show(progId);
          

        }
    }
}

  

c#获取com对象的progid

上一篇:Windows ( Win10 ) 下 安装 Lua 包管理工具 Luarocks ( 非 binary 版) 安装教程


下一篇:变量命名规范(c#,前端)