LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

eject USB device programatically

I have an application which runs modal and hides the OS, this application requires the user to insert and remove usb flash drives.  Is there any api call to remove a USB drive?  I am able to find the drives with a search of D-Z:\ but I need to be able to eject the drive with a button on the Front panel.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 1 of 12
(5,666 Views)

Try this article:

Community Admin Note:  The article link has been removed due to invalid information.

 
0 Kudos
Message 2 of 12
(5,654 Views)
Thanks I will give it a try.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 12
(5,629 Views)

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.




metzler CLAD
0 Kudos
Message 4 of 12
(4,782 Views)

@metzler wrote:

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.


Plug-n-Pray. has gotten a bit better in the last 9 years.  With Win 7 and later my experience has been something like " If the Device can't be hot swapped on a USB port - Trash the obsolete device."  Not a common point of view.  Realistic though!

 

Lets look at the phy layer on a modern USB device.  Yup, "The Physical Layer"  all four connections!  Take a close look.  did you notice that two of the four conductors are just a bit shorter than the others?  Data lines are disconnected before 5V and Gnd. 5V and Gnd are connected before data lines.  Works like a charm.


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 12
(4,754 Views)

@JÞB wrote:

@metzler wrote:

I know this is an old post, but this is what I am looking for.

I tried this with Win7 and am not convinced it works.  The program responds that the drive was ejected, but the computer can still access the drive.  Do you know if there is an updated version for Win7?

Thanks.


Plug-n-Pray. has gotten a bit better in the last 9 years.  With Win 7 and later my experience has been something like " If the Device can't be hot swapped on a USB port - Trash the obsolete device."  Not a common point of view.  Realistic though!

 

Lets look at the phy layer on a modern USB device.  Yup, "The Physical Layer"  all four connections!  Take a close look.  did you notice that two of the four conductors are just a bit shorter than the others?  Data lines are disconnected before 5V and Gnd. 5V and Gnd are connected before data lines.  Works like a charm.


I think the main reason for 'safely removing hardware' is in the case of USB memory sticks where a write operation might not have completed if you just pull out the drive randomly. I think it's gotten a bit better in newer versions of windows (e.g. turning off/reducing write caching) but obviously if you were copying/writing to a file, the 'safely remove hardware' is a check to make sure any outstanding writes are complete.

 

Reference:

f78cdf98acb28496ba3a7499ecfa2ef00ef00a4003edb4d94564165e622ed518.jpg


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 6 of 12
(4,718 Views)
Thanks for the information and quick response. So, as long as my LabView program writes to the USB drive and provides ample time afterwards, the computer should no longer be writing to the drive, and I can issue instructions to the user to remove the USB drive? If correct, is there a way to determine how long is ample time to write to the drive? I am worried that Windows might (quickly) write to it, then access every couple of minutes for some (stupid) reason.



metzler CLAD
0 Kudos
Message 7 of 12
(4,689 Views)

@OEM_Dev wrote:

You're probably OK by default

 

 

See

http://www.pcworld.com/article/254868/safely_remove_usb_drives_just_by_unplugging_them.html


nice link!


"Should be" isn't "Is" -Jay
Message 9 of 12
(4,666 Views)
Thanks, I will assume everything is okay with removing it after writing a small file. .



metzler CLAD
0 Kudos
Message 10 of 12
(4,621 Views)