Initial
Исходный код версии 2.0
This commit is contained in:
145
sources/cdejecter/__history/cdejecter.lpr;9
Normal file
145
sources/cdejecter/__history/cdejecter.lpr;9
Normal file
@@ -0,0 +1,145 @@
|
||||
program cdejecter;
|
||||
{$mode delphi}
|
||||
{$codepage UTF8}
|
||||
uses Interfaces, {$IFDEF UNIX}{$IFDEF UseCThreads}cthreads,{$ENDIF}{$ENDIF} Classes, SysUtils, CustApp, ANBFormatString,
|
||||
cde_lang, dynlibs, cde_types;
|
||||
type
|
||||
{ TCDEjecter }
|
||||
TCDEjecter = class(TCustomApplication)
|
||||
protected
|
||||
procedure DoRun; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); OVERRIDE;
|
||||
destructor Destroy; OVERRIDE;
|
||||
procedure WriteHelp; VIRTUAL;
|
||||
procedure ListDiscs (const Extendend: Boolean);
|
||||
function FormatDiscInfo (const AString: String; const AInfo: TDiscInfo): String;
|
||||
procedure ShowDiscInfo (const ADisc: String);
|
||||
procedure EjectDisc (const ADisc: String);
|
||||
end;
|
||||
{ TCDEjecter }
|
||||
procedure TCDEjecter.DoRun;
|
||||
var isHandled: Boolean;
|
||||
begin
|
||||
WriteLn('--------------------------------------------------------------------');
|
||||
WriteLn('**************************** CD Ejecter ****************************');
|
||||
WriteLn('*************************** Версия: 1.2 ***************************');
|
||||
WriteLn('******* Авторские права (c) 2011 - 2017, Александр Бабаев **********');
|
||||
WriteLn('--------------------------------------------------------------------');
|
||||
|
||||
|
||||
{ add your program here }
|
||||
|
||||
// stop program loop
|
||||
Terminate;
|
||||
end;
|
||||
constructor TCDEjecter.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create (TheOwner);
|
||||
StopOnException:= True;
|
||||
end;
|
||||
destructor TCDEjecter.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
procedure TCDEjecter.WriteHelp;
|
||||
begin
|
||||
writeln(FormatStr(GetLocalizedString(cde_messages_help), ['$newline$'], [#13#10]));
|
||||
end;
|
||||
procedure TCDEjecter.ListDiscs (const Extendend: Boolean);
|
||||
var DLL: TLibHandle;
|
||||
GetCDDiscs: function: PChar;
|
||||
GetVolumeInfo: function (const ADisc: WideChar): TDiscInfo;
|
||||
SL: TStringListUTF8;
|
||||
Msg: String;
|
||||
Indx: Integer;
|
||||
DInfo: TDiscInfo;
|
||||
begin
|
||||
Msg:= '';
|
||||
SL:= TStringListUTF8.Create;
|
||||
DLL:= SafeLoadLibrary('cdejecter.dll');
|
||||
GetCDDiscs:= GetProcAddress(DLL, 'GetCDDiscs');
|
||||
GetVolumeInfo:= GetProcAddress(DLL, 'GetVolumeInfo');
|
||||
SL.Delimiter:= ';';
|
||||
SL.DelimitedText:= GetCDDiscs;
|
||||
if SL.Count > 0 then
|
||||
for Indx:= 0 to SL.Count - 1 do
|
||||
begin
|
||||
DInfo:= GetVolumeInfo(WideChar(SL[Indx][1]));
|
||||
if not (Trim(Msg) = '') then
|
||||
Msg:= Msg + #13#10;
|
||||
Msg:= Msg + SL[Indx];
|
||||
if Extendend then
|
||||
if DInfo.diHasInfo then
|
||||
Msg:= Msg + ' - ' + DInfo.diVolumeName
|
||||
else
|
||||
Msg:= Msg + ' - ' + GetLocalizedString(cde_messages_nodiscorempty);
|
||||
end;
|
||||
FreeLibrary(DLL);
|
||||
SL.Free;
|
||||
WriteLn(GetLocalizedString(cde_messages_discslist));
|
||||
WriteLn(Msg);
|
||||
end;
|
||||
function TCDEjecter.FormatDiscInfo (const AString: String; const AInfo: TDiscInfo): String;
|
||||
begin
|
||||
Result:= FormatStr(AString,
|
||||
['$newline$',
|
||||
'$letter$',
|
||||
'$volumename$',
|
||||
'$filesystem$',
|
||||
'$serial$'
|
||||
],
|
||||
[#13#10,
|
||||
AInfo.diDrive,
|
||||
AInfo.diVolumeName,
|
||||
AInfo.diFileSystem,
|
||||
IntToStr(AInfo.diSerial)
|
||||
]);
|
||||
end;
|
||||
procedure TCDEjecter.ShowDiscInfo (const ADisc: String);
|
||||
var DLL: TLibHandle;
|
||||
GetVolumeInfo: function (const ADisc: WideChar): TDiscInfo;
|
||||
Msg: String;
|
||||
DInfo: TDiscInfo;
|
||||
begin
|
||||
DLL:= SafeLoadLibrary('cdejecter.dll');
|
||||
GetVolumeInfo:= GetProcAddress(DLL, 'GetVolumeInfo');
|
||||
DInfo:= GetVolumeInfo(WideChar(ADisc[1]));
|
||||
FreeLibrary(DLL);
|
||||
if DInfo.diHasInfo then
|
||||
Msg:= FormatDiscInfo(GetLocalizedString(cde_messages_discdesc), DInfo)
|
||||
else
|
||||
Msg:= FormatDiscInfo(GetLocalizedString(cde_messages_discdesconerror), DInfo);
|
||||
WriteLn(GetLocalizedString(cde_messages_discinfo));
|
||||
WriteLn(Msg);
|
||||
end;
|
||||
procedure EjectDisc (const ADisc: String);
|
||||
var DLL: TLibHandle;
|
||||
EjectCD: function (const ADisc: WideChar): Boolean;
|
||||
GetVolumeInfo: function (const ADisc: WideChar): TDiscInfo;
|
||||
Msg: String;
|
||||
DInfo: TDiscInfo;
|
||||
begin
|
||||
DLL:= SafeLoadLibrary('cdejecter.dll');
|
||||
GetVolumeInfo:= GetProcAddress(DLL, 'GetVolumeInfo');
|
||||
EjectCD:= GetProcAddress(DLL, 'EjectCD');
|
||||
DInfo:= GetVolumeInfo(WideChar(ADisc[1]));
|
||||
if EjectCD (WideChar(ADisc[1])) then
|
||||
Msg:= FormatDiscInfo(GetLocalizedString(cde_messages_ejectsuccess), DInfo)
|
||||
else
|
||||
Msg:= FormatDiscInfo(GetLocalizedString(cde_messages_ejecterror), DInfo);
|
||||
FreeLibrary(DLL);
|
||||
if not HasParam('silent') then
|
||||
begin
|
||||
WriteLn(GetLocalizedString(cde_messages_ejecttitle));
|
||||
WriteLn(Msg);
|
||||
end;
|
||||
end;
|
||||
var Application: TCDEjecter;
|
||||
{$R *.res}
|
||||
begin
|
||||
Application:= TCDEjecter.Create(Nil);
|
||||
Application.Title:= 'CD Ejecter';
|
||||
Application.Run;
|
||||
Application.Free;
|
||||
end.
|
Reference in New Issue
Block a user