473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

windows service detect usb

hi,
I found a lot of programs that detect usb devices in c#.
but i need to make windows service program that detect usb.
can someone help me???
Dec 23 '09 #1
14 5328
NitinSawant
270 100+
just create new windows service project in visual studio..

thats it
Dec 23 '09 #2
it dosen't help me. all the programs I now are with forms that catching messages from windows.
forms are not abled in sindows service
Dec 28 '09 #3
Plater
7,872 Expert 4TB
You can probably use WMI classes.
Win32_DeviceChangeEvent triggers when devices are added or removed.
You could probably key off that event to check to see if the device you wanted exists


Tie it in with PnPDevice:
Expand|Select|Wrap|Line Numbers
  1.  try
  2.             {
  3.                 ManagementObjectSearcher searcher = 
  4.                     new ManagementObjectSearcher("root\\CIMV2", 
  5.                     "SELECT * FROM Win32_PnPEntity"); 
  6.  
  7.                 foreach (ManagementObject queryObj in searcher.Get())
  8.                 {
  9.                     Console.WriteLine("-----------------------------------");
  10.                     Console.WriteLine("Win32_PnPEntity instance");
  11.                     Console.WriteLine("-----------------------------------");
  12.                     Console.WriteLine("Caption: {0}", queryObj["Caption"]);
  13.                     Console.WriteLine("ClassGuid: {0}", queryObj["ClassGuid"]);
  14.                     Console.WriteLine("Description: {0}", queryObj["Description"]);
  15.                     Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
  16.                     Console.WriteLine("Name: {0}", queryObj["Name"]);
  17.                     Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
  18.                     Console.WriteLine("Service: {0}", queryObj["Service"]);
  19.                     Console.WriteLine("Status: {0}", queryObj["Status"]);
  20.                 }
  21.             }
  22.             catch (ManagementException e)
  23.             {
  24.                 MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
  25.             }
  26.  
Dec 28 '09 #4
Plater,
Do you have the whole windows service project that detect usb?
Dec 29 '09 #5
Dheeraj Joshi
1,123 Expert 1GB
Use WMI to achieve this.

This link may help WMI and USB

Regards
Dheeraj Joshi
Dec 29 '09 #6
I used the code that in the link above.
but it doesn't work.
do someone have widows service project that detect USD devic?
( or at least code that works well)
Dec 30 '09 #7
Dheeraj Joshi
1,123 Expert 1GB
The link was to give an idea. You need to write your own code(I did not tried to execute the code in that link. But i wrote my own code which detected USB connection/Disconnections).

Regards
Dheeraj Joshi
Dec 30 '09 #8
Can you bring me the cide you wrote?
Dec 30 '09 #9
Dheeraj Joshi
1,123 Expert 1GB
You can also use Temporary or permanent even consumers to do this job.

Regards
Dheeraj Joshi
Dec 30 '09 #10
soryy, i meen code not cide
Dec 30 '09 #11
Dheeraj Joshi
1,123 Expert 1GB
Na.... I can not the post here... It belong to some organization...

Regards
Dheeraj Joshi

Note: Its easy to write the code. Give a try :-)
Dec 30 '09 #12
Can you give me an idea?
I am new programer. and i nedd it very necessary.
thanx
Dec 30 '09 #13
Plater
7,872 Expert 4TB
Best advice to give a new programmer:
Start reading up APIs and function calls and working things out for yourself. Give it a try.
Dec 30 '09 #14
If someone anyway can bring me project it will be very good.
I need this ASAP
Dec 30 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
2
by: Benoit Martin | last post by:
Is it possible to detect a mouse click from a .net service. I want a process running in the background that will detect when the user clicks the mouse button (anywhere on the screen) and executes...
5
by: Mark Rae | last post by:
Hi, I'm looking for advice concerning what to do if a Windows service does not find a "viable" working environment at startup. E.g. I have a Windows service which does the following: 1)...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
6
by: Roger Twomey | last post by:
Can a .Net web form interact with a .Net web service? More importantly... How? I have written a web-service which runs on a timer to check for data in a database that needs to be 'operated' on....
3
by: Chris Dunaway | last post by:
I am writing a Windows Service that reads and processes files on a set schedule. I want to create a second app that can monitor the Windows service. The Windows service will write trace messages...
1
by: Tom Yee | last post by:
I would like to write a Windows Service that can communicate with any open browser windows that an interactive user may be running. The service itself does not need to have a UI. The company...
3
by: =?Utf-8?B?RGlvZ28gQWx2ZXMgLSBTb2Z0d2FyZSBEZXZlbG9w | last post by:
Greetings, I would like to create a windows service that would expect an event from my software to import data from a device and/or to import data in scheduled times My questions are: - How...
2
by: arcade2084 | last post by:
I am trying to detect when a CD is inserted from a windows service. I have went through the route of creating a hiden window and trying to use the WndProc to detect the event; although the window...
1
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I am reviewing Windows service programming. I'm running VS2005 and programming in VB. I've just found an example in Support: 'How to create a Setup project for a Windows Service in Visual Basic...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.