Uniquely identifying a pendrive - c#

I am working on USB devices and can identify a usb device. But I have a theoretical question.Is it shows any usb device like portable cd drive or specifically flash drives? I could nt check all possibilities due to lack of these hardwares :). Is there any method to identify if it is a flash drive or another usb device.
Please don't beat with what you have tried. I googled regarding same but because of my least experience I couldn't find any.
Thanks

Please use the class USBSerialNumber
USBSerialNumber usb = new USBSerialNumber();
string serial = usb.getSerialNumberFromDriveLetter("f:\");
MessageBox.Show(serial);
Each pendrive has serial number which is unique.
You can use this class for this purpose.
Download it from following link:
http://www.cfdan.com/posts/Retrieving_Non-Volatile_USB_Serial_Number_Using_C_Sharp.cfm

Related

Split a serial port device into two virtual COM's but with another app in the middle that controls data flow

Good day,
As the title says.
Split a serial port device into two virtual COM's but with another app in the middle that controls data flow.
So i have this project and is my first time bumping into something like this. I have two Applications lets name them (Apple and Tomato) that have to use the same physical device, lets call this device COM1.
Now problem is that on Windows you can't have two applications using the same COM Port, so i thought ok lets split COM1 into COM10 and COM11 using a third party app.
Everything worked well until i saw that they tried to read and write information and physical device wen't crazy and could't understand what is going on and same for Apple and Tomato. So i'm stuck.
New idea and here i need some help with info and some code examples, case studies, whatever you guys can help with is appreciated.
Idea is to emulate physical device COM1 and tell Apple that he has a device and Tomato that he has another device, just like above, but only this time i would control the information sent to the real physical device over my emulator.

c# communicating with an usb port

I'm trying to contact an usb barcode scanner as a serial port, using his virtual COM port name and the Serial Port class.
The reason I'm trying to do it this way is to avoid using the scanner as a keyboard wedge since I need the possibility to scan even when the form is hidden.
Problem is that when I connect the barcode scanner to the usb port, and I run the "GetPortNames" function, I get an empty list. Any suggestions why? Thanks
Typically many USB barcode scanners will just appear as virtual keyboard devices - not virtual COM ports. That would explain why it doesn't appear.
Does your scanner support some kind of serial emulation mode? You may need to configure it or install different drivers to enable this. Does it appear as a serial port in Device Manager? (Look under the Ports tree)
As an aside:
Take a look at this question if you find that the 'keyboard mode' is the only one supported:
Reading a barcode using a USB barcode scanner along with ignoring keyboard data input while scanner product id and vendor id are not known
This question refers to this article with a large amount of good information relating to keyboard hooks and filtering out the scanned barcodes:
http://nicholas.piasecki.name/blog/2009/02/distinguishing-barcode-scanners-from-the-keyboard-in-winforms/
I cannot guarantee that it will work with your specific device, but I've seen code that solved a similar problem once. The solution was looking for the port name in the registry.
The code for it can be found in the open source project ez430chronosnet; a .NET library that can access TI's EZ430 Chronos watch via its USB dongle.
You'll want to look at the PortName.cs file that looks for the name in the registry (it will at least point you to the right keys) and the Chronos.cs file that does the actual port opening with SerialPort.

Getting Info on NON_HID USB Device

How can I get details on NON-HID USB Devices? Like the serial number, etc in c#?
I have created successfully a sample application to retrieve those information on HID only devices but not on NON-HID USB Devices.
Have you looked into LibUSB .Net?
http://sourceforge.net/projects/libusbdotnet/
I remmber seeing that this was possible, I'll try and dig the article out.
You want to retrieve the device descriptors. Assuming a driver has been bound to the device, some of these are already available as they can be seen from Device Manager.

How to detect USB Wifi plug into computer via C#?

I want to write a simple program that detect USB Wifi plugged computer and unplug it. I am finding code or library help me to do that (C# or Delphi). Tell me if you know :)
Or
Code or lib that list all USB devices on computer ?
Thanks !
I can only answer part of the question. You can "eject" USB devices using this API:
CM_Request_Device_Eject (MSDN link)
I'm using it to eject USB thumb drives after I copy stuff onto them in a backup application. I'm pretty sure there are ways of enumerating available USB devices using one of the many CM_XXX routines, but I was only interested in storage devices connected via USB, so I can't comment on WiFi devices.
An other sugestion: Maybe you can solve your problem at an other layer, maybe you can detect the addition of a new network adapter and disable that. Not all USB devices can be ejected, it's probably a driver-related issue. But I guess, if you can eject it from the notification area icon, you can eject it from code.
may have a look at http://sourceforge.net/projects/libusbdotnet/ (never used it by myself)

How to use computer's Bluetooth to send Wallpapers to any cellphone, in C#?

I'd like to know if it is possible how to do it, because my client asked me if the program I'm developing could also send wallpapers to nearby cellphones(my program will be in a place with many people passing by, so it would be good to have the bluetooth feature).
Thanks!
it can send pictures as files, users then may set them as wallpapers.
Unless the phone and the computer support bluetooth and are connected, you cannot. You can send the files to mobiles over bluetooth. 32feet provides a nice library to perform bluetooh related operations. Try that.
Hope it helps.
To do this you would need to
Make sure each user's device is paired to your bluetooth "sever"
Create the ability to auto connect and send the file.
On your phone's application, receive the image file and set the phone background - this will be different for each type of phone's OS. I would assume you are aiming towards Window Mobile Devices, since you are using c#.
The first step i see as being the difficult step as each phone much "register" the bluetooth of the server to be paired with it.

Categories

Resources