Jump to content

Programatically eject USB Flash


PauloM

Recommended Posts

Hello,

I want to programmatically eject my USB Flash memory from the PC.

In my application, the user doesn't have access to the system tray and to windows explorer (at least I try to...), but he can insert some USB memory drives, to get data from the system. The problem is that, in this way, the drive will be constantly removed from the system without ejecting it.

Does anyone know how to eject removable drives from LabVIEW?

Thanks in advance for the help,

Paulo

Link to comment
I want to programmatically eject my USB Flash memory from the PC.

Google on Q165721, a Microsoft KB article (roughly) entitled 'HOWTO: Eject Removeable Media in WinNT/2K/XP'. I didn't read all the way through, looks like they're doing DeviceIOCtrl calls. You may be able to use a couple of CLNs to access the Win32 system to do what you need.

Hope this gets you started,

Dave

Link to comment
  • 2 years later...

QUOTE(David Boyd @ Mar 17 2005, 08:47 AM)

Google on Q165721, a Microsoft KB article (roughly) entitled 'HOWTO: Eject Removeable Media in WinNT/2K/XP'. I didn't read all the way through, looks like they're doing DeviceIOCtrl calls. You may be able to use a couple of CLNs to access the Win32 system to do what you need.

Hope this gets you started,

Dave

Dave,

Interesting link. However, the main problem that Paulo will have is that when LabVIEW accesses a flash drive it keeps a reference open to the drive until LV is completely shut down. There are several programs that will do this (even some MS ones). They will keep a reference open to the last drive they accessed. The only way I have found around this behaviour is to either shut down the offending program or access a different drive (do not know if this works w/LV). Aslo, many of us are CLN 'challenged' and the article is so much Greek :blink: .

Anyone have a solution out there?

Link to comment

QUOTE(rkesmodel @ May 16 2007, 10:41 PM)

Dave,

Interesting link. However, the main problem that Paulo will have is that when LabVIEW accesses a flash drive it keeps a reference open to the drive until LV is completely shut down. There are several programs that will do this (even some MS ones). They will keep a reference open to the last drive they accessed. The only way I have found around this behaviour is to either shut down the offending program or access a different drive (do not know if this works w/LV). Aslo, many of us are CLN 'challenged' and the article is so much Greek :blink: .

Anyone have a solution out there?

I don't think it is an application thing really. It is the more likely the "current directory" Windows maintains on a per process base. Various Windows APIs such as the File Dialog box do adjust the current directory to the last directory accessed. So that is where the notion of applications locking a drive may come from.

Another one is that LabVIEW keeps a handle to DLLs open as soon as they got loaded into memory until the application closes down completely. I'm sure the new LabVIEW 8.2.1 feature to define the DLL path dynamically at runtime for Call Library Nodes can actually remove that annoyence once the VI accessing that DLL has gone idle.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.