You are here

remove for PAM

10 posts / 0 new
Last post
iamacooldude
Offline
Last seen: 16 years 1 week ago
Joined: 2006-11-29 19:18
remove for PAM

I have been editing the Delphi source that John handed out with the last release so I could add in removing the drive after exiting.(Like u3) I am getting an error code 5. Could someone with more Delphi knowledge help?

Here is the code I added into the imgCloseClick event procedure:

var
h: THandle; i: integer;   Drive: String;  dw: dword; bback:Boolean;  errorstr:String; sq:integer;
begin
//This part will eject the drive and exit, but will throw an error if it can't. 
Drive:=  ExtractFileDrive(Application.ExeName);
h:=CreateFile(PChar('\\.\'+Drive), 0, 0, nil,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if h=INVALID_HANDLE_VALUE then MessageBox(Application.Handle,'invalid','error',MB_APPLMODAL);
bback:=DeviceIOControl(h,{IOCTL_STORAGE_EJECT_MEDIA,$90020}$2d4808	, nil, 0, nil, 0, dw, nil);
i:=GetLastError;   CloseHandle(h);
if i=6  then   errorstr:='Device In Use' else errorstr:='Error Code:'+IntToStr(i);
if bback=false then
begin
MessageBox(Application.Handle,PChar(errorstr),'Error',MB_APPLMODAL);
sq:=MessageBox(Application.Handle,'Still Quit?','quit?',MB_YESNO);
 end
 else
 begin
  bolFadeToExit := true;
  FadeInOut(false);
  end;
    if sq=IDYES then
    begin
  bolFadeToExit := true;
  FadeInOut(false);
    end;
end;
El Salvador
Offline
Last seen: 14 years 2 months ago
Joined: 2005-12-09 10:10
Error code 5 is

Error code 5 is ERROR_ACCESS_DENIED.

iamacooldude
Offline
Last seen: 16 years 1 week ago
Joined: 2006-11-29 19:18
okay...

So does that mean the device is "busy"? I have noticed I get "unable to eject device"/"generic device could not be stopped" from windows after I use this... If that is so, I'm not sure how I would exactly go about fixing that.

Nobody should start to undertake a large project. You start with a small _trivial_ project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse,

Steve Lamerton
Steve Lamerton's picture
Offline
Last seen: 10 years 6 months ago
Developer
Joined: 2005-12-10 15:22
I'm

guessign that it's because you are running PAM off the drive and then telling it to unload the drive, but it can't because it is running on it, if you see what I mean.

Yours

Steve Lamerton

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
The ideal solution

would be to copy itself to the Temp directory and then eject.
----
Ryan McCue
Person 1: Oh my god. You will never believe what just happened.
Person 2: What?
Person 1: I can't remember, I've forgotten.

"If you're not part of the solution, you're part of the precipitate."

Simeon
Simeon's picture
Offline
Last seen: 9 years 5 months ago
DeveloperTranslator
Joined: 2006-09-25 15:15
But then

you would have the same problem U3 has:
You must have a proggy to delete the stuff and the last file will remain on the PC.
Or is there something I'm missing?

"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate

iamacooldude
Offline
Last seen: 16 years 1 week ago
Joined: 2006-11-29 19:18
...

it would seem that way, but it acts no different if running from the desktop.

Nobody should start to undertake a large project. You start with a small _trivial_ project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse,

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
Actually

It can load itself into RAM, then delete it's physical location (unlink).
----
Ryan McCue
Person 1: Oh my god. You will never believe what just happened.
Person 2: What?
Person 1: I can't remember, I've forgotten.

"If you're not part of the solution, you're part of the precipitate."

iamacooldude
Offline
Last seen: 16 years 1 week ago
Joined: 2006-11-29 19:18
...

is there any internal delphi way to do this besides what I've done.(I mean without another library like JEDI, which I can't seem to get to work.)

Nobody should start to undertake a large project. You start with a small _trivial_ project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse,

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 14 years 6 months ago
Joined: 2006-01-06 21:27
Dunno

But I'm fairly sure NSIS loads the installer into memory. At least, it does for uninstallers.
----
Ryan McCue
Person 1: Oh my god. You will never believe what just happened.
Person 2: What?
Person 1: I can't remember, I've forgotten.

"If you're not part of the solution, you're part of the precipitate."

Topic locked