AE中通過UID使用getLayer

UID的官方解釋是:


COM interfaces and coclasses are identified by a globally unique identifier (GUID). The GUID for an interface is called an interface ID (IID). The GUID for a coclass is called class ID (CLSID). A ProgID is a text alias for a CLSID; the ProgID is a string composed of the project name and the class name of the coclass. The UID coclass can be used to represent the GUID of an object.

如何獲取GUID:
 1.在註冊表中使用查找功能,查找接口名稱,即可發現要找的GUID;
 2.通過代碼獲取。
    1)代碼如下
       string uid = (typeof(IFeatureLayer)).GUID.ToString();
       MessageBox.Show("所查詢的GUID爲:"+uid); 

    2)UID中value的幾種值以及表示的意思:

          {6CA416B1-E160-11D2-9F4E-00C04F6BC78E}   IDataLayer

          {40A9E885-5533-11d0-98BE-00805F7CED21}   IFeatureLayer

          {E156D7E5-22AF-11D3-9F99-00C04F6BC78E}   IGeoFeatureLayer

          {34B2EF81-F4AC-11D1-A245-080009B6F22B}   IGraphicsLayer

          {5CEAE408-4C0A-437F-9DB3-054D83919850}   IFDOGraphicsLayer

          {0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E}   ICoverageAnnotationLayer

          {EDAD6644-1810-11D1-86AE-0000F8751720}    IGroupLayer

UID使用示例:

        /// <summary> 
        /// 獲取圖層 
        /// </summary> 
        /// <returns></returns> 
        private IEnumLayer GetLayers()
        {

            //UID puid = new UIDClass();
            //string uid = (typeof(IFeatureLayer)).GUID.ToString();
            //puid.Value = "{" + uid + "}";


            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";

            IEnumLayer layers = mainMapControl.Map.get_Layers(uid, true);
            return layers;
        }




發佈了12 篇原創文章 · 獲贊 5 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章