{"id":661,"date":"2009-10-02T19:25:00","date_gmt":"2009-10-02T11:25:00","guid":{"rendered":""},"modified":"2013-11-17T12:49:07","modified_gmt":"2013-11-17T04:49:07","slug":"c%e8%b0%83%e7%94%a8dll%e5%85%a5%e9%97%a8%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/661.html","title":{"rendered":"C#\u8c03\u7528DLL\u5165\u95e8\u793a\u4f8b"},"content":{"rendered":"<p>\u7b80\u5355\u5730\u5b66\u4e60\u4e86\u4e00\u4e0b\u9759\u6001\u8c03\u7528\uff0c\u52a8\u6001\u8c03\u7528\u8c8c\u4f3c\u6709\u70b9\u9ebb\u70e6\uff0c\u4ee5\u540e\u518d\u6162\u6162\u7814\u7a76\u3002<\/p>\n<p>C#\u8c03\u7528DLL\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel;\r\nusing System.Data;\r\nusing System.Drawing;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Windows.Forms;\r\nusing System.Runtime.InteropServices;\r\n\r\nnamespace Csharp_Delphi_DLL_DEMO1\r\n{\r\n    public partial class Form1 : Form\r\n    {\r\n        &#x5B;DllImport(&quot;dll1.dll&quot;, EntryPoint = &quot;Triple&quot;)]\r\n        static extern int Triple(int i);\r\n        public Form1()\r\n        {\r\n            InitializeComponent();\r\n        }\r\n\r\n        private void Form1_Load(object sender, EventArgs e)\r\n        {\r\n\r\n        }\r\n\r\n        private void button1_Click(object sender, EventArgs e)\r\n        {\r\n            int i = int.Parse(textBox1.Text);\r\n            label1.Text = Convert.ToString(Triple(i));\r\n        }\r\n    }\r\n}\r\n\r\n<\/pre>\n<p>\u987b\u8981\u52a0\u5165\u547d\u540d\u7a7a\u95f4\uff1ausing System.Runtime.InteropServices;<\/p>\n<p>DLL\u6587\u4ef6\u4ee3\u7801\uff1a<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nlibrary dll1;\r\n\r\nuses\r\n  SysUtils,\r\n  Classes,\r\n  Dialogs;\r\n\r\n{$R *.res}\r\n \/\/\u5efa\u7acb\u8fc7\u7a0b\r\nfunction Triple(N:Integer):integer;stdcall;\r\nbegin\r\n       result:=N+3;\r\nend;\r\n\r\n\/\/\u8f93\u51fa\r\nexports\r\n  Triple;\r\n\r\nbegin\r\nend.\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u5355\u5730\u5b66\u4e60\u4e86\u4e00\u4e0b\u9759\u6001\u8c03\u7528\uff0c\u52a8\u6001\u8c03\u7528\u8c8c\u4f3c\u6709\u70b9\u9ebb\u70e6\uff0c\u4ee5\u540e\u518d\u6162\u6162\u7814\u7a76\u3002 C#\u8c03\u7528DLL\u4ee3\u7801\uff1a using Syste [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-661","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=661"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/661\/revisions"}],"predecessor-version":[{"id":4602,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/661\/revisions\/4602"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}