Trouble with Win 10 writing files to a USB device - vb.net

I have a USB device with flash memory that looks like a USB FAT16 flash drive to a PC. The device stores VB.net product support software files.
As part of the flash update process the device firmware re-formats flash memory and sets the media change state. Win XP thru Win 8.1 refresh the devices file system and the device shows as an empty drive. From there we copy. Works great.
Windows 10 (since the anniversary update) doesn't pay attention to the media change state. After the device re-formats the flash Win 10 still shows all the files that have been erased. Copying files at this point fails. The only way to recover is to unplug, then plug in the USB connector.
I have tried using DeviceIoControl(IOCTL_INTERNAL_USB_CYCLE_PORT) from my application. This only sometimes works.
Is there a better way to programmatically force Win 10 to refresh its view of the USB flash in the device without unplugging it?

Related

on windows 7/8, how to read usb device descriptor from a usb camera, and read picture stream with webcam meanwhile

I use webcam-capture(java api) to get video stream from a usb camera, it work fine.
I want read a usb device descriptor(store some private information), i find out that should install WinUSB or libusbk as a driver to the usb devices. and it test ok, read the descriptor success (by libusb_control_transfer api)
the question is:
befor I install WinUSB, the usb camera is a camera device in the windows device management list. the LibUSB work fail, can't open the usb devices, the error number is -5, means entrypoin not find
after I install WinUSB, libUSB api work ok, but the webcam program can't open the usb devices, it is a universal usb device in the windows device management list.
is there some way the webcam work ok, at the same time, i can read the usb device descriptor use libusb or use other something?
i tested on windows 7 and windows 8, have the same problem.
thanks.
Sadly this is not possible because each of your applications needs a different driver. The only way this can work is if you use libusb and build you own capturing api on top which is quite complicated. As long as webcam-capture can not read the data you want to know about the webcam I am afraid this is not possible.

How to use usb flash or virtual drive to act as a plug and play device?

I am trying to find a way to mimic a USB device being connected without actually having it available. I am trying to develop an additional feature to software that is only fully unlocked when the USB device is connected to the computer. Because the client is unable to provide a demo device for me to use here shortly, I'd like to find a way to emulate or mimic the connectivity of the device so I can finish development. Can I do this with a flash drive perhaps? Find someway to copy the files so that when I insert the flash drive it acts as a plug and play device?

Get type of device inserted to windows 8 pc via USB port

I've been asked to work on a project for Windows 8 where I have to detect:
Type of device inserted to USB port (mass storage drive or android phone or windows phone etc.)
Port in which device was inserted. (if I have 4 USB ports in PC then identify which port received new device)
Detect when the device was ejected from the PC
Are there some managed C# API's that can be used to query or if there are some callbacks that can be subscribes to.
Any help or direction will be very useful.
Thanks
You don't specify whether you are writing a desktop app, or a Modern UI app. If it is the latter, I'm afraid you are going to be out of luck as this level of information is simply not passed down to the app's sandbox.
You may have better luck with a desktop app. I don't have any direct experience of doing what you ask for, but I do remember having read that it may be possible through .NET.

USB HOST mode in ICS

I'm trying to connect a usb sensor (see Toradex) to an android phone (Desire Z) running android 4.0.3.
To test this, I wrote a small app to enumerate the attached device(s).
This supposed to have USB HOST mode implemented and to power the usb sensor (HID)... but it doesn't.
I got a USB OTG cable and now, when I attach the cable, a small icon appears in the status bar (car mode).
I'm disappointed since I waited for this feature for awhile now...
Any thoughts? I read almost everything out there related to this (Sven work and whatnot) but I might have missed something...
Thanks!
I have worked a lot in the past year and a half to build custom android platform. Some was under Froyo but mostly on Gingerbread. Most on the hardware I added was on either a UART or on USB, which is what you want to do. Unfortunately, it is not as easy to add a USB peripheral on an Android device than on a PC or a MAC. PCs and MACs have virtually unlimited memory space (hard drive). They can hold the drivers of a very large number of devices. That makes it possible to do auto-detection and automatic loading of drivers. On an Android device, it is a lot more lean therefor, just the required drivers are stored on the device. Every time I added a new device, I had to compile the driver for my platform and make some modification in my configuration. It is also possible to load the driver as a module instead of compiling it with the kernel (gives a file.ko output). Although, the driver must have been written accordingly. But, you will have to install it by modifying the "init.rc" which requires root privilege.
here is a few link of question/answer about about drivers in Android. That should give you a little bit more info:
USB touchscreen driver
Hope it helps but unfortunately, it is quiet a lot of work do do.

Autorun when USB stick is inserted

I'm trying to prompt users to run my installer, whenever they plug in my USB device. I'd like this to work on all (most?) Windows OSes.
I have an autorun.inf file in the root dir of my USB key with these contents:
[Autorun]
ShellExecute=setup.exe
Icon=setup.exe
UseAutoplay=1
It doesn't seem to do very much at all. Well... it does change the icon properly, but nothing gets executed and the user doesn't get any prompts. I've tried it on both Windows 7 and Windows Server 2003.
Any ideas?
USB mass storage devices do not perform Autorun on Windows. You need to enumerate as a USB CD-ROM device in order to support autorun.
If you have a U3 capable USB drive, you can often replace the U3 data with your own CD image.
If this is a custom USB device, you will need to implement a composite device with the Mass Storage and USB CD-ROM device (or just the CD-ROM if you don't want to supporting writing).