Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Shutdown and Eject USB Disk

Posted on 2005-05-16
Medium Priority
Last Modified: 2007-11-27
Hi all,
Anyone can help me how to create a function to shutdown/eject USB Disk just what windows done by click Safely Remove Hardware Icon in systray. I wonder there's a function with drive parameter, examp: ShutDownUSB(driveletter: char)

Question by:matelindonesia
LVL 11

Expert Comment

ID: 14010454
The function is called CM_Request_Device_Eject and is located in the Config Manager API.
Get both Zips from http://www.sf.net/projects/jedi-apilib
In "Setup and Config Manager API" you will find an example precisely for what you want to do.

Expert Comment

ID: 14015909
I've try the example code, and installed the JEDI component(JVCL and JCL), but why it always ask the JwaDbt unit?

FYI I used Jedi component ver 3.00

LVL 11

Expert Comment

ID: 14015962
Because this is the Jedi-Apilib which is a conversion of the Win32 API.
Add the path to the directory where you unpacked the jedi-apilib files to the library path of Delphi.
Also to the Setup API conversion.
Sorry, these files have no installer yet.
Industry Leaders: 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: 14016109
Oke, I've add the library path for win32 api and Setup API Conversion, It works, but why whe it entered the FillDriveList procedure, excatly on GetDriveInstanceID procedure it raised EAccessViolation.
FYI I've code on WinXP OS with SP2, is it make any influence?
LVL 11

Accepted Solution

robert_marquardt earned 1000 total points
ID: 14016674
Please debug further. I see no obvious bugs.
For the debugging contact me directly robert_marquardt att gmx dott de
No need to discuss that here.

Author Comment

ID: 14044927
Thanks to robert_marquardt,

I finally got solution after looking for it since last year,
BRAVO ...!!!


LVL 11

Expert Comment

ID: 14045112
For other readers:
The problem with the demo program was that i tested it only under Win 2000.
The bug in the Setup API conversion was Win XP specific. That resulted in the demo not being able to access the Setup API at all when compiled for Win XP.

I do know more about CM_Request_Device_Eject. Better not try to use it from a service.
There are numerous quirks in that API resulting in unwanted Surprise Removal dialogs popping up.

Expert Comment

ID: 14286537
I got the same problem, how do I solve it? Please help.
LVL 11

Expert Comment

ID: 14287632
The bug is in cfgmgr32.pas. I converted CM_Is_Version_Available and CM_Is_Version_Available_Ex, but these functions are not in cfgmgr32.dll.
Search for "CM_Is_Version_Available" and comment out *all* occurrences.
These functions are in fact a bad trick of MS Visual Studio. It uses cfgmgr.lib instead of cfmgr32.lib to link to the DLL and these functions
are implemented in the lib whereas most other functions are delegated to the DLL as usual.

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

571 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