{"id":46145,"date":"2023-10-01T01:58:25","date_gmt":"2023-09-30T17:58:25","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=46145"},"modified":"2023-10-01T01:58:25","modified_gmt":"2023-09-30T17:58:25","slug":"sywhqudk","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/46145.html","title":{"rendered":"\u4f7f\u7528WinForm\u83b7\u53d6USB\u7aef\u53e3"},"content":{"rendered":"

  \u968f\u7740\u79d1\u6280\u7684\u53d1\u5c55\uff0cUSB\u7aef\u53e3\u5df2\u7ecf\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u5b83\u4eec\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u6253\u5370\u673a\u3001\u5916\u90e8\u5b58\u50a8\u8bbe\u5907\u3001\u6e38\u620f\u63a7\u5236\u5668\u7b49\u5916\u90e8\u8bbe\u5907\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528WinForm\u6765\u83b7\u53d6USB\u7aef\u53e3\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n

\u4ec0\u4e48\u662fWinForm\uff1f<\/h2>\n

  WinForm\uff08\u7a97\u4f53\u5e94\u7528\u7a0b\u5e8f\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u521b\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u6280\u672f\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e\u5f00\u53d1Windows\u5e94\u7528\u7a0b\u5e8f\uff0c\u5305\u62ec\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u3001\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u548cWeb\u5e94\u7528\u7a0b\u5e8f\u3002WinForm\u53ef\u4ee5\u4f7f\u7528C#\u3001VB.NET\u548cC++\u7b49\u8bed\u8a00\u7f16\u5199\uff0c\u5e76\u4f7f\u7528.NET\u6846\u67b6\uff0c\u652f\u6301\u591a\u79cd\u6280\u672f\uff0c\u5982Windows Forms\u3001WPF\u3001ASP.NET\u548cWCF\u7b49\u3002<\/p>\n

\u5982\u4f55\u4f7f\u7528WinForm\u83b7\u53d6USB\u7aef\u53e3\uff1f<\/h2>\n

  \u6b65\u9aa4\u4e00\uff1a\u521b\u5efaWinForm\u5e94\u7528\u7a0b\u5e8f<\/h3>\n

  \u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2aWinForm\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u7a97\u4f53\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u6309\u94ae\uff0c\u7528\u4e8e\u83b7\u53d6USB\u7aef\u53e3\u3002<\/p>\n

  \u6b65\u9aa4\u4e8c\uff1a\u6dfb\u52a0\u4ee3\u7801<\/h3>\n

  \u7136\u540e\uff0c\u9700\u8981\u5728\u6309\u94ae\u7684\u5355\u51fb\u4e8b\u4ef6\u4e2d\u6dfb\u52a0\u4ee3\u7801\uff0c\u7528\u4e8e\u83b7\u53d6USB\u7aef\u53e3\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

  \/\/ \u83b7\u53d6USB\u7aef\u53e3<\/p>

  string[] ports = System.IO.Ports.SerialPort.GetPortNames();<\/p>

  \/\/ \u904d\u5386\u6240\u6709USB\u7aef\u53e3<\/p>

  foreach (string port in ports)<\/p>

  {<\/p>

   Console.WriteLine(port);<\/p>

  }<\/p><\/pre>\n

  \u6b65\u9aa4\u4e09\uff1a\u7f16\u8bd1\u5e94\u7528\u7a0b\u5e8f<\/h3>\n

  \u6700\u540e\uff0c\u9700\u8981\u5c06\u5e94\u7528\u7a0b\u5e8f\u7f16\u8bd1\uff0c\u4ee5\u4fbf\u5c06\u5176\u90e8\u7f72\u5230\u5ba2\u6237\u7aef\u4e0a\u3002\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5e94\u7528\u7a0b\u5e8f\u83b7\u53d6USB\u7aef\u53e3\uff0c\u4ece\u800c\u66f4\u597d\u5730\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  \u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528WinForm\u83b7\u53d6USB\u7aef\u53e3\u3002<\/strong>\u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2aWinForm\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5728\u7a97\u4f53\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u6309\u94ae\uff0c\u7528\u4e8e\u83b7\u53d6USB\u7aef\u53e3\u3002\u7136\u540e\uff0c\u9700\u8981\u5728\u6309\u94ae\u7684\u5355\u51fb\u4e8b\u4ef6\u4e2d\u6dfb\u52a0\u4ee3\u7801\uff0c\u7528\u4e8e\u83b7\u53d6USB\u7aef\u53e3\u3002\u6700\u540e\uff0c\u9700\u8981\u5c06\u5e94\u7528\u7a0b\u5e8f\u7f16\u8bd1\uff0c\u4ee5\u4fbf\u5c06\u5176\u90e8\u7f72\u5230\u5ba2\u6237\u7aef\u4e0a\u3002\u4f7f\u7528\u6b64\u65b9\u6cd5\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u4f7f\u7528USB\u7aef\u53e3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u968f\u7740\u79d1\u6280\u7684\u53d1\u5c55\uff0cUSB\u7aef\u53e3\u5df2\u7ecf\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u5b83\u4eec\u53ef\u4ee5\u7528\u6765\u8fde\u63a5\u6253\u5370\u673a\u3001\u5916\u90e8\u5b58\u50a8\u8bbe\u5907\u3001\u6e38\u620f\u63a7\u5236\u5668\u7b49\u5916\u90e8\u8bbe\u5907\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528WinForm\u6765\u83b7\u53d6USB<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[294],"class_list":["post-46145","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-usb"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/46145"}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=46145"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/46145\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=46145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=46145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=46145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}