Сейчас на форуме: (+5 невидимых) |
![]() |
eXeL@B —› Программирование —› Execute file from CD delphi |
Посл.ответ | Сообщение |
|
Создано: 14 октября 2007 22:24 · Личное сообщение · #1 Hi :...... I need some help : I have executable file “MY.exe” I want if Current drive is hard disk then search all CDROMS for it self “MY.exe” if fined then run “MY.exe” from CD where it is be founded. Else If Current drive is CDROM then…..Do something). I write code but when it runs from hard drive and call “MY.exe” from CDROM the executed file behave as it was executed from hard drive and called itself again.( program 'thinks' it is not running from cd-rom) Here is the code: //-------------------------------------------------------------------- ----------------------------------------------------------------- procedure check;external 'mydll.dll'; function CurDrv: Char; var s1: string; s2: Char; begin GetDir(0,s1); s2 := s1[1]; CurDrv := s2; end; //-------------------------------------------------------------------- ---------- Procedure TForm1.Protect; var a: Char; wOldErrorMode : Word; begin wOldErrorMode := SetErrorMode( SEM_FAILCRITICALERRORS ) ; dcDiskInfo1.Disk:= CurDrv;//(Disk Controls component) i used another function but same result. if dcDiskInfo1.DriveType=dtCDROM then begin check; Application.Terminate; end else begin if dcDiskInfo1.DriveType<>dtCDROM then begin For a := 'A' to 'Z' Do if GetDriveType(pChar(a + ':\) = DRIVE_CDROM Then begin if (FileExists(a+':\BA.exe')<> false)then begin ShellExecute(Handle, 'open', Pchar(a+':\BA.exe'), '', '', SW_SHOWNORMAL); end else Showmessage('Please inser disk in drive'); Application.Terminate; try finally SetErrorMode( wOldErrorMode ) ; end; end; end; end; end; Thank you ![]() |
|
Создано: 14 октября 2007 22:35 · Поправил: Enigma · Личное сообщение · #2 |
|
Создано: 14 октября 2007 23:02 · Поправил: depler · Личное сообщение · #3 |
|
Создано: 14 октября 2007 23:07 · Личное сообщение · #4 |
|
Создано: 14 октября 2007 23:30 · Личное сообщение · #5 |
|
Создано: 14 октября 2007 23:44 · Личное сообщение · #6 |
|
Создано: 14 октября 2007 23:45 · Личное сообщение · #7 |
|
Создано: 15 октября 2007 00:04 · Поправил: Enigma · Личное сообщение · #8 Did you try to debug this code? What string fails? My advice is to change this string with GetDriveType function. dcDiskInfo1.Disk:= CurDrv;//(Disk Controls component) i used another function but same result. Man, for what you use this checkup "if dcDiskInfo1.DriveType<>dtCDROM then" ??? it is always return true in your case! Amazing :-D what are you trying to handle??? try finally SetErrorMode( wOldErrorMode ) ; end; ![]() |
|
Создано: 15 октября 2007 00:36 · Личное сообщение · #9 Procedure TForm1.Protect; var a: Char; wOldErrorMode : Word; begin wOldErrorMode := SetErrorMode( SEM_FAILCRITICALERRORS ) ; dcDiskInfo1.Disk:= CurDrv; if dcDiskInfo1.DriveType=dtCDROM then begin check; Application.Terminate; end else begin try For a := 'A' to 'Z' Do begin if GetDriveType(pChar(a + ':') = DRIVE_CDROM Then begin if (FileExists(a+':\BA.exe')<> false)then begin ShellExecute(0, 'open', Pchar(a+':\BA.exe'), '', '', SW_SHOWNORMAL); end else Showmessage('Please inser disk in drive'); Application.Terminate; finally SetErrorMode( wOldErrorMode ) ; end; end; end; end; end; I got creazy what's wrong now?DIDN'T WORK still calling itself. ![]() |
|
Создано: 15 октября 2007 02:53 · Личное сообщение · #10 |
|
Создано: 15 октября 2007 08:01 · Личное сообщение · #11 var S:string; I:integer; begin S:='S'; if GetDriveType(PChar(ExtractFileDrive(Application.ExeName)))<>DRIVE_CDRO M then begin for I:=67 to 90 do begin S[1]:=Char(I); if GetDriveType(PChar(S+':'))=DRIVE_CDROM then begin If FileExists(S+':\MyFile.exe') then begin WinExec(PChar(S+':\MyFile.exe'),SW_SHOWNORMAL); application.Terminate; end; end; end; end; ShowMessage('Insert correct CD-ROM!'); ![]() |
|
Создано: 15 октября 2007 16:11 · Личное сообщение · #12 |
![]() |
eXeL@B —› Программирование —› Execute file from CD delphi |
Эта тема закрыта. Ответы больше не принимаются. |