1. <legend id='Vq3xy'><style id='Vq3xy'><dir id='Vq3xy'><q id='Vq3xy'></q></dir></style></legend>

      <tfoot id='Vq3xy'></tfoot>
      <i id='Vq3xy'><tr id='Vq3xy'><dt id='Vq3xy'><q id='Vq3xy'><span id='Vq3xy'><b id='Vq3xy'><form id='Vq3xy'><ins id='Vq3xy'></ins><ul id='Vq3xy'></ul><sub id='Vq3xy'></sub></form><legend id='Vq3xy'></legend><bdo id='Vq3xy'><pre id='Vq3xy'><center id='Vq3xy'></center></pre></bdo></b><th id='Vq3xy'></th></span></q></dt></tr></i><div id='Vq3xy'><tfoot id='Vq3xy'></tfoot><dl id='Vq3xy'><fieldset id='Vq3xy'></fieldset></dl></div>

      <small id='Vq3xy'></small><noframes id='Vq3xy'>

        <bdo id='Vq3xy'></bdo><ul id='Vq3xy'></ul>

      如何关闭另一个程序使用的串口

      时间:2023-11-10

          <small id='JhE6x'></small><noframes id='JhE6x'>

            <tbody id='JhE6x'></tbody>
          <i id='JhE6x'><tr id='JhE6x'><dt id='JhE6x'><q id='JhE6x'><span id='JhE6x'><b id='JhE6x'><form id='JhE6x'><ins id='JhE6x'></ins><ul id='JhE6x'></ul><sub id='JhE6x'></sub></form><legend id='JhE6x'></legend><bdo id='JhE6x'><pre id='JhE6x'><center id='JhE6x'></center></pre></bdo></b><th id='JhE6x'></th></span></q></dt></tr></i><div id='JhE6x'><tfoot id='JhE6x'></tfoot><dl id='JhE6x'><fieldset id='JhE6x'></fieldset></dl></div>
            <bdo id='JhE6x'></bdo><ul id='JhE6x'></ul>
            <legend id='JhE6x'><style id='JhE6x'><dir id='JhE6x'><q id='JhE6x'></q></dir></style></legend>

              <tfoot id='JhE6x'></tfoot>
              • 本文介绍了如何关闭另一个程序使用的串口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在编写一个 SerialPort 程序.有时当我想打开 SerialPort 时,会抛出 UnauthorizedAccessException :拒绝访问 COM1.这是因为另一个程序(由其他人编写,我没有它的源代码)正在使用 COM1,并且该程序在退出时不会关闭 COM1.我想问两个问题:

                I'm writting a SerialPort program. Sometimes when I want to open the SerialPort, an UnauthorizedAccessException is thrown :access to COM1 is denied. This is beause another program( which is written by someone else and I don't have its soucecode ) is using COM1, and that program doesn't close COM1 when it exits. I want to ask 2 questions:

                1. 使用时如何用我的代码(尤其是C#代码)关闭COM1由另一个程序?
                2. 如果无法使用 C# 代码关闭 COM1,如何在 Windows 操作系统中关闭或释放 COM1?

                谢谢.

                推荐答案

                这个 Stack Overflow 问题是第一步:如何在 C# 中按进程获取打开文件句柄列表?

                This Stack Overflow question is the first step: How do I get the list of open file handles by process in C#?

                一旦你有了它,你可以修改那里的代码来关闭句柄,或者干脆杀死打开句柄的进程.

                Once you have that, you can modify the code there to close the handle, or simply kill the process that has the handle open.

                但是,这非常危险*,容易出现问题,并且需要根据特定部署(x32 与 x64 与 ARM)以及COM1"在特定机器上映射的内容进行重新设计.

                This, however, is very risky*, prone to problems, and will need to be re-engineered based on specific deployments (x32 vs x64 vs ARM) plus what 'COM1' maps to on that particular machine.

                有风险:如果串行端口用于例如在手机或类似设备上安装新固件 - 关闭端口可能会导致设备变砖.如果端口正在用于传输数据,则关闭端口可能会导致数据丢失.

                On Risk: If the serial port is being used to, for instance, install new firmware on a phone or similar - closing the port may result in bricking the device. If the port is being used to transfer data, then closing the port may result in losing data.

                祝你好运.但是,如果您破坏系统或丢失数据,请不要怪我.

                Good luck. But please do NOT blame me if you destroy your system or lose data.

                这篇关于如何关闭另一个程序使用的串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何正确使用 SerialPort.DiscardInBuffer? 下一篇:SerialPort 数据丢失 - C#

                相关文章

                  • <bdo id='65vRQ'></bdo><ul id='65vRQ'></ul>

                    <tfoot id='65vRQ'></tfoot>

                    <small id='65vRQ'></small><noframes id='65vRQ'>

                    <legend id='65vRQ'><style id='65vRQ'><dir id='65vRQ'><q id='65vRQ'></q></dir></style></legend>
                    <i id='65vRQ'><tr id='65vRQ'><dt id='65vRQ'><q id='65vRQ'><span id='65vRQ'><b id='65vRQ'><form id='65vRQ'><ins id='65vRQ'></ins><ul id='65vRQ'></ul><sub id='65vRQ'></sub></form><legend id='65vRQ'></legend><bdo id='65vRQ'><pre id='65vRQ'><center id='65vRQ'></center></pre></bdo></b><th id='65vRQ'></th></span></q></dt></tr></i><div id='65vRQ'><tfoot id='65vRQ'></tfoot><dl id='65vRQ'><fieldset id='65vRQ'></fieldset></dl></div>