In our project, we’ve received a requirement where the the user is to be capable of enabling/disabling a COM Port / USB Port / Ethernet Port via our application’s gui.
Is it possible to manipulate harware’s enabled/disabled state programatically in C#?
According to responses in this discussion thread, USB ports can be disabled by modifying a registry key. You can certainly do that in C#.
In general, this is really a Windows hardware question more than a C# question. C# does not have any special access or control of hardware – anything you want to do in C# will have to be done using the Windows OS APIs or configuration tools. Just about any unmanaged Windows API can be called from managed .NET code (C# or otherwise) using .NET’s PInvoke.