zoukankan      html  css  js  c++  java
  • 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);
              
    
            }
        }
    }
    

      

    有些com组件跟设置有关系,如下图

  • 相关阅读:
    多窗口页面(Frames)
    页面(PAGE)标记(TAGS)
    表单(FORM)标记(TAGS)
    会移动的文字(Marquee)
    MediaPlayer控件的初探
    ADO.net实现数据库连接(1)
    ListView初认识
    TreeView控件
    初识敏捷开发
    新的征程
  • 原文地址:https://www.cnblogs.com/coolyylu/p/12535395.html
Copyright © 2011-2022 走看看