Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2008, 06:09 AM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default check device connect to PC by c#

hi all
I want to check , if a device (e.g. printer) with serial port ( or usb) connect to my computer or not ?and get the name of the device (e.g. Printer).
How can do it by using c#?
thanx very lot
Regards

 
Old May 2nd, 2008, 07:39 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There are a lot of e.g.'s in that statement.

If what you actually want is a list of installed printers, then just say so.

System.Drawing.Printing.PrinterSettings.InstalledP rinters




/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 07:53 AM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx for ur reply ,
but how can i get the name of device connect to my PC !
regards

 
Old May 2nd, 2008, 09:20 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

System.Drawing.Printing.PrinterSettings.InstalledP rinters is an array of strings, which are the names of the installed printers. What more do you need?

/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 12:34 PM
Registered User
 
Join Date: May 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks and yes you are right , for e.g. for a printer , we have :
Code:
PrintDialog pr = new PrintDialog();
string str = pr.PrinterSettings.PrinterName.ToString();
MessageBox.Show(str);
but suppose COM1 , connect to monitor port , how can i get the name of device connect to this port "COM1" , or how can we recognize what device connect to this COM1 .
THANKS

 
Old May 2nd, 2008, 01:59 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I'll be honest, I don't know.

You might be able to get some of that kind of information through WMI, but I wouldn't know how.


/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect to VSS check-in Check-out Programatically rhd110 General .NET 6 August 12th, 2007 07:46 AM
How do I connect do a device using ethernet. SGarcia Visual Basic 2005 Basics 0 October 24th, 2006 03:35 PM
Can't connect to SQL server 2000 in local PC shalim SQL Server 2000 1 November 24th, 2005 01:09 AM
Detecting Pocket PC device on Browser johnnycorpse Classic ASP Basics 2 May 25th, 2005 07:57 AM
vb.net smart device pocket pc and xml BlueIce6 VB.NET 0 February 16th, 2005 05:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.