Solved Salfy remove (eject) USB device

Posted on 2009-05-09
Last Modified: 2012-05-06
I'm writing a code (MS visual basic express)
my code is working as following:
1. it detects USB device arrival, and get the drive letter.
2. Using drive letter, it can do some functions on the device.
3. I need a pre-made function that safely remove the external USB device after finish from step2.

It been two weeks of searching for such code with no luck. I've found many codes but non did work for me since most of them give errors in MS visual basic express 2008.
these two codes gave less errors. However, after correcting errors using the editor's suggestions they didn't work as they supposed to!

So, help be to find suitable (and WORKING) code that disconnects the removable device with the following properties:
1. Target OS = Windows XP
2. Target language = (MS Visual Basic Express 2008)
Question by:sniper038
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 83

Expert Comment

ID: 24345914

Author Comment

ID: 24346040
Thank for replying, actually I've found lots of working apps that do the same thing I need. But the problem is that I can't find or getting it working in
I may try to convert the codeproject you've provided into VB but am not sure that i'll be able to achieve that.
LVL 83

Accepted Solution

CodeCruiser earned 500 total points
ID: 24346054
Do not convert it. I think its a dll. If not, just copy the class into a C# DLL project and compile into a DLL. This way you can use it without converting it.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 24346081
Huh.... I really have no idea about what you're taking about!

Anyway, if in some way I can do that, Am I going to be able to just call it from my VB code with drive letter passed, and have that drive ejected?
LVL 83

Expert Comment

ID: 24346090

Author Comment

ID: 24346119
I'll start reading and trying to do the DLL thing the next few days. But however, I would prefer any straight forward solution in since I only have (MS VB express edition) and don't like to install any further products unless I have to. So, If anyone has that EXTREMITY HARD to implement code in it will be appreciated and will be considered as the right and exact answer for my question.

Author Comment

ID: 24399964
I tried to achieve the DLL thing but it gets complicated!!
I still prefer a direct solution with VB.

Author Closing Comment

ID: 31579822
it wasn't the solution I wanted but anyway it was the keyword

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question