{"id":6828,"date":"2016-03-23T14:05:59","date_gmt":"2016-03-23T05:05:59","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=6828"},"modified":"2016-03-23T14:05:59","modified_gmt":"2016-03-23T05:05:59","slug":"typelibrary%e3%81%8b%e3%82%89%e5%88%97%e6%8c%99%e5%9e%8b%e3%81%ae%e6%83%85%e5%a0%b1%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8bc%e3%82%b3%e3%83%bc%e3%83%89","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=6828","title":{"rendered":"TypeLibrary\u304b\u3089\u5217\u6319\u578b\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308bC#\u30b3\u30fc\u30c9"},"content":{"rendered":"<p><a href=\"http:\/\/excelfactory.net\/excelboard\/excelvba\/excel.cgi\" title=\"Excel Q&#038;A\u30b5\u30ed\u30f3(VBA)\" target=\"_blank\">Excel Q&#038;A\u30b5\u30ed\u30f3<\/a>\u306b\u300c<a href=\"http:\/\/excelfactory.net\/excelboard\/excelvba\/excel.cgi?mode=all&#038;namber=175103\" title=\"\u5217\u6319\u578b\u306e\u4e00\u89a7\u3092\u8868\u793a\" target=\"_blank\">\u5217\u6319\u578b\u306e\u4e00\u89a7\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u305f\u3044<\/a>\u300d\u3068\u306e\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u624b\u306e\u51e6\u7406\u306f\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=4585\" title=\"\u7d44\u307f\u8fbc\u307f\u5b9a\u6570\u3092\u5217\u6319\u3059\u308bVBA\u30de\u30af\u30ed | \u521d\u5fc3\u8005\u5099\u5fd8\u9332\" target=\"_blank\">\u7d44\u307f\u8fbc\u307f\u5b9a\u6570\u3092\u5217\u6319\u3059\u308bVBA\u30de\u30af\u30ed<\/a>\u300d\u3067\u3082\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u304c\u3001TypeLib Information(tlbinf32.dll)\u3092\u5229\u7528\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001tlbinf32.dll\u306f\u300c<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/vstudio\/ms788708.aspx\" title=\"Windows Vista \u304a\u3088\u3073 Windows Server 2008 \u306b\u5bfe\u3059\u308b Visual Basic 6.0 \u306e\u30b5\u30dd\u30fc\u30c8\u306b\u95a2\u3059\u308b\u58f0\u660e\" target=\"_blank\">Windows Vista \u304a\u3088\u3073 Windows Server 2008 \u306b\u5bfe\u3059\u308b Visual Basic 6.0 \u306e\u30b5\u30dd\u30fc\u30c8\u306b\u95a2\u3059\u308b\u58f0\u660e<\/a>\u300d\u306b\u3042\u308b\u3088\u3046\u306b\u3001Windows Vista\u4ee5\u964d\u3001\u3059\u3067\u306b\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3001\u4eca\u56de\u306f\u5225\u306e\u65b9\u6cd5\u3092\u8003\u3048\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u53c2\u8003\u306b\u3057\u305f\u306e\u306f\u3053\u3061\u3089\u2193\u306e\u30da\u30fc\u30b8\u3002<\/p>\n<p><strong>\u30fb\u30bf\u30a4\u30d7\u30e9\u30a4\u30d6\u30e9\u30ea<\/strong><br \/>\n<a href=\"http:\/\/eternalwindows.jp\/com\/auto\/auto02.html\" title=\"\u30bf\u30a4\u30d7\u30e9\u30a4\u30d6\u30e9\u30ea\" target=\"_blank\">http:\/\/eternalwindows.jp\/com\/auto\/auto02.html<\/a><\/p>\n<p>LoadTypeLib\u3067TypeLibrary\u3092\u53d6\u5f97\u3057\u3066\u3001GetTypeInfo\u3084\u3089GetVarDesc\u3084\u3089\u3092\u4f7f\u3063\u3066\u3044\u3051\u3070\u3001\u51e6\u7406\u3067\u304d\u305d\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u3053\u308c\u3092VBA\u3067\u3084\u308b\u3068\u30b7\u30f3\u30c9\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u4eca\u56de\u306fC#\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">using System;\r\nusing System.Runtime.InteropServices;\r\nusing ComTypes = System.Runtime.InteropServices.ComTypes;\r\n\r\nnamespace ListTypeLibInfo\r\n{\r\n  class Program\r\n  {\r\n    &#x5B;DllImport(&quot;oleaut32.dll&quot;, PreserveSig=false)]\r\n    public static extern ComTypes.ITypeLib LoadTypeLib(&#x5B;In, MarshalAs(UnmanagedType.LPWStr)] string typelib);\r\n    \r\n    public static void Main(string&#x5B;] args)\r\n    {\r\n      ComTypes.ITypeLib lib;\r\n      try {\r\n        lib = LoadTypeLib(@args&#x5B;0]);\r\n      } catch (Exception ex) {\r\n        Console.WriteLine(&quot;Error:&quot; + ex.Message);\r\n        \/\/Console.ReadKey(true);\r\n        return;\r\n      }\r\n      for (int i = 0; i &lt; lib.GetTypeInfoCount(); i++) {\r\n        IntPtr ppta;\r\n        ComTypes.ITypeInfo info;\r\n        int con;\r\n        string sname, doc, hlp;\r\n        lib.GetTypeInfo(i, out info);\r\n        info.GetDocumentation(-1, out sname, out doc, out con, out hlp);\r\n        info.GetTypeAttr(out ppta);\r\n        try {\r\n          ComTypes.TYPEATTR ta = (ComTypes.TYPEATTR)Marshal.PtrToStructure(ppta, typeof(ComTypes.TYPEATTR));\r\n          if (ta.typekind == ComTypes.TYPEKIND.TKIND_ENUM) {\r\n            for (int j = 0; j &lt; ta.cVars; j++) {\r\n              IntPtr ppvd;\r\n              int pcnames;\r\n              string&#x5B;] names = {string.Empty};\r\n              info.GetVarDesc(j, out ppvd);\r\n              try {\r\n                ComTypes.VARDESC vd = (ComTypes.VARDESC)Marshal.PtrToStructure(ppvd, typeof(ComTypes.VARDESC));\r\n                info.GetNames(vd.memid, names, 1, out pcnames);\r\n                Console.WriteLine(&quot;{0}\\t{1}\\t{2}&quot;, sname, names&#x5B;0], Marshal.GetObjectForNativeVariant(vd.desc.lpvarValue));\r\n              } finally {\r\n                info.ReleaseVarDesc(ppvd);\r\n              }\r\n            }\r\n          }\r\n        } finally {\r\n          info.ReleaseTypeAttr(ppta);\r\n        }\r\n      }\r\n      \/\/Console.Write(&quot;Press any key to continue . . . &quot;);\r\n      \/\/Console.ReadKey(true);\r\n    }\r\n  }\r\n}<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\n\u69cb\u9020\u4f53\u306e\u89e3\u653e\u51e6\u7406\u3042\u305f\u308a\u304c\u7279\u306b\u81ea\u4fe1\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u5b9f\u884c\u3059\u308b\u3068\u4e00\u5fdc\u6307\u5b9a\u3057\u305f\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u5217\u6319\u578b\u306e\u60c5\u5831\u3092\u629c\u304d\u51fa\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/www.ka-net.org\/blog\/wp-content\/uploads\/ListTypeLibInfo_01.jpg\" alt=\"ListTypeLibInfo_01\" width=\"677\" height=\"492\" class=\"alignnone size-full wp-image-6829\" srcset=\"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/ListTypeLibInfo_01.jpg 677w, https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/ListTypeLibInfo_01-300x218.jpg 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/p>\n<p>\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u5b9f\u969b\u306b\u3084\u3063\u3066\u307f\u3066\u601d\u3063\u305f\u3053\u3068\u306f\u3001\u3084\u306f\u308a\u300c<span style=\"color: #ff0000; font-weight: bold;\">TypeLib Information(tlbinf32.dll)<\/span>\u3092\u4f7f\u3063\u305f\u65b9\u304c\u697d\uff01\u300d\u3060\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>tlbinf32.dll\u306foleaut32.dll\u306e\u30e9\u30c3\u30d1\u30fc\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001TypeLibrary\u306e\u60c5\u5831\u3092\u629c\u304d\u51fa\u3057\u305f\u3044\u3068\u304d\u306f\u30db\u30f3\u30c8\u4fbf\u5229\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Excel Q&#038;A\u30b5\u30ed\u30f3\u306b\u300c\u5217\u6319\u578b\u306e\u4e00\u89a7\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u305f\u3044\u300d\u3068\u306e\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002 \u3053\u306e\u624b\u306e\u51e6\u7406\u306f\u300c\u7d44\u307f\u8fbc\u307f\u5b9a\u6570\u3092\u5217\u6319\u3059\u308bVBA\u30de\u30af\u30ed\u300d\u3067\u3082\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u304c\u3001TypeLib Information(tlbinf [&hellip;]","protected":false},"author":1,"featured_media":7122,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[TypeLibrary\u304b\u3089\u5217\u6319\u578b\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308bC#\u30b3\u30fc\u30c9]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[],"class_list":["post-6828","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Other.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-1M8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6828"}],"version-history":[{"count":1,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6828\/revisions"}],"predecessor-version":[{"id":6830,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6828\/revisions\/6830"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7122"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}