• 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组件跟设置有关系,如下图

  • 相关阅读:
    GCD HDU
    Finding Lines UVALive
    Chinese Mahjong UVA
    DNA Evolution CodeForces
    String Reconstruction (并查集)
    Number Cutting Game HDU
    Paint the Wall ZOJ
    Star sky CodeForces
    Haunted Graveyard ZOJ
    GuGuFishtion HDU
  • 原文地址:https://www.cnblogs.com/coolyylu/p/12535395.html
Copyright © 2020-2023  润新知