views:

1192

answers:

1

Hello,

I've a application that must work after another application. This second application has a bug that causes COM ports not to be closed in specific circumstances.

I would like to close all COM ports programmatically in my application to ensure, that there will be no bugs about close ports reported. Is it possible if I do not own objects that opened COM ports?

I need a solution on .NET Framework, C# .

+2  A: 

There is no good, easy way:

  • A good way is to fix the other application; or if that's impossible, to write a filter device driver (similar to the parport driver but for serial ports instead of parallel ports) which would sit on top of the serial port hardware driver and which would expose more than one connection point (one used by the other application, which passes through to the underlying real driver, and another 'back door' used by your own application ... the real driver would only see one client, i.e. the filter driver wich sits on top of it)
  • An easy way is to nuke (forcibly terminate) the other process.
ChrisW