Click here to Skip to main content
15,916,527 members
Home / Discussions / Hardware & Devices
   

Hardware & Devices

 
AnswerRe: require the h/w devices Pin
Jonathan Davies2-May-09 3:29
Jonathan Davies2-May-09 3:29 
AnswerRe: require the h/w devices Pin
Dave Kreskowiak2-May-09 5:33
mveDave Kreskowiak2-May-09 5:33 
QuestionWDF driver for ISA Pin
William R. Price28-Apr-09 2:16
William R. Price28-Apr-09 2:16 
AnswerRe: WDF driver for ISA Pin
Yama Fuji2-May-09 19:22
Yama Fuji2-May-09 19:22 
AnswerRe: WDF driver for ISA Pin
Randor 3-May-09 21:00
professional Randor 3-May-09 21:00 
QuestionApplication gets stuck after writing on to COM Port Pin
Sifar - 023-Apr-09 19:26
Sifar - 023-Apr-09 19:26 
AnswerRe: Application gets stuck after writing on to COM Port Pin
Luc Pattyn24-Apr-09 2:27
sitebuilderLuc Pattyn24-Apr-09 2:27 
AnswerRe: Application gets stuck after writing on to COM Port Pin
dybs24-Apr-09 15:41
dybs24-Apr-09 15:41 
Is this a USB device using a virtual COM port? If so, here's what I do to find the COM port it's connected to.

NOTE: I'm not sure what the standard practice is for this, there may be a better way, but this was worked just fine for me so far. If anyone knows of a better, more robust way to do this, I'm open to suggestions.

You can determine which COM port the device is connect to by searching the registry under
HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_xxxx

where xxxx is the hex identifier for the VendorID and ProductID of the device. Inside this key is another subkey for each instance of the device, and then in the Device Parameters key you'll see PortName (I think, can't remember off hand exactly what it is). Anyway, the name of the COM port can be found here. You can iterate through each instance in the registry and attempt to open the .NET SerialPort object. If you successfully open the port, then the device is connected.

So you'll want to look for the key
HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_xxxx\<all subkeys="">\Device Parameters</all>

and read the PortName value from each instance.

foreach(string curPortName in portNames)
{
    port.Name = curPortName;
    try
    {
        port.Open();
        // Will only break if port.Open() succeeds and does not throw an exception.
        break;
    }
    catch(InvalidOperationException ex)
    {
        // COM port does not exist, device not connected
    }
    catch(UnauthorizedAccessException ex){
        // COM Port already open
    }
}


You can check the MSDN documentation for how to read info from the Registry in C#.

Dybs
GeneralRe: Application gets stuck after writing on to COM Port Pin
Sifar - 028-Apr-09 4:53
Sifar - 028-Apr-09 4:53 
QuestionWindows Mobile Waiting Cursor Pin
miguelji21-Apr-09 7:03
miguelji21-Apr-09 7:03 
AnswerRe: Windows Mobile Waiting Cursor Pin
Luc Pattyn21-Apr-09 7:37
sitebuilderLuc Pattyn21-Apr-09 7:37 
GeneralRe: Windows Mobile Waiting Cursor Pin
miguelji21-Apr-09 8:13
miguelji21-Apr-09 8:13 
AnswerRe: Windows Mobile Waiting Cursor Pin
Tim Layton5-May-09 2:34
Tim Layton5-May-09 2:34 
GeneralRe: Windows Mobile Waiting Cursor Pin
miguelji6-May-09 17:52
miguelji6-May-09 17:52 
GeneralRe: Windows Mobile Waiting Cursor Pin
doananhtai15-Jun-09 17:11
doananhtai15-Jun-09 17:11 
GeneralRe: Windows Mobile Waiting Cursor Pin
miguelji15-Jun-09 21:07
miguelji15-Jun-09 21:07 
Question% Processor Time of CPU Pin
M. J. Jaya Chitra15-Apr-09 1:08
M. J. Jaya Chitra15-Apr-09 1:08 
AnswerRe: % Processor Time of CPU Pin
Dan Neely15-Apr-09 2:49
Dan Neely15-Apr-09 2:49 
AnswerRe: % Processor Time of CPU Pin
Randor 15-Apr-09 18:56
professional Randor 15-Apr-09 18:56 
GeneralRe: % Processor Time of CPU Pin
M. J. Jaya Chitra15-Apr-09 19:23
M. J. Jaya Chitra15-Apr-09 19:23 
QuestionMETHOD_BUFFERED when using DeviceIoControl Pin
Shay Harel14-Apr-09 6:02
Shay Harel14-Apr-09 6:02 
AnswerRe: METHOD_BUFFERED when using DeviceIoControl Pin
Randor 15-Apr-09 19:12
professional Randor 15-Apr-09 19:12 
GeneralRe: METHOD_BUFFERED when using DeviceIoControl Pin
Shay Harel16-Apr-09 2:18
Shay Harel16-Apr-09 2:18 
QuestionHow can I send the command CE to a PIN PAD Pin
yera200210-Apr-09 13:07
yera200210-Apr-09 13:07 
AnswerRe: How can I send the command CE to a PIN PAD Pin
Luc 64801110-Apr-09 14:33
Luc 64801110-Apr-09 14:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.