144 lines
4.8 KiB
Plaintext
144 lines
4.8 KiB
Plaintext
unit kernel;
|
||
{$mode delphi}
|
||
{$codepage UTF8}
|
||
interface
|
||
uses windows, Classes, SysUtils, FileUtil, StdCtrls, shlobj, comobj, ActiveX, registry, Forms, SimplyJSON, LazFileUtils,
|
||
dynlibs, LazUTF8Classes, cde_types, Controls;
|
||
{stdcall}
|
||
procedure UpdateDL (var DL: TComboBox); stdcall;
|
||
function GetVolumeInfoFVS (const Dir: String; var FileSystemName, VolumeName: String; var Serial: LongInt): Boolean; STDCALL;
|
||
procedure CreateShortCut(ShortCutName, Parameters, FileName: string); stdcall;
|
||
function GetDesktopDir: string; stdcall;
|
||
procedure UpdateLanguage; stdcall;
|
||
function ShowMessageBox (const AText: string; const AMessageType: Longint; const AMessageBtns: Longint = 0): integer; stdcall;
|
||
procedure CreateDriveRec (const ADrive: WideChar); STDCALL;
|
||
implementation
|
||
uses cde_MainForm, ch_languageform, cde_LinkCreatorForm, cde_DriveAdderForm,
|
||
cde_disc_frame;
|
||
procedure UpdateDL (var DL: TComboBox);
|
||
var DLL: TLibHandle;
|
||
GetCDDiscs: function: PChar;
|
||
SL: TStringListUTF8;
|
||
begin
|
||
DL.Items.Clear;
|
||
SL:= TStringListUTF8.Create;
|
||
DLL:= SafeLoadLibrary('cdejecter.dll');
|
||
GetCDDiscs:= GetProcAddress(DLL, 'GetCDDiscs');
|
||
SL.Delimiter:= ';';
|
||
SL.DelimitedText:= GetCDDiscs;
|
||
FreeLibrary(DLL);
|
||
DL.Items.AddStrings(SL);
|
||
DL.ItemIndex:= 0;
|
||
SL.Free;
|
||
end;
|
||
function GetVolumeInfoFVS (const Dir: String; var FileSystemName, VolumeName: String; var Serial: LongInt): Boolean;
|
||
{Получение информации о диске
|
||
Dir - каталог или буква требуемого диска
|
||
FileSystemName - название файловой системы
|
||
VolumeName - метка диска
|
||
Serial - серийный номер диска
|
||
В случае ошибки функция возвращает false}
|
||
var DLL: TLibHandle;
|
||
GetVolumeInfo: function (const ADisc: WideChar): TDiscInfo;
|
||
DiscInfo: TDiscInfo;
|
||
begin
|
||
DLL:= SafeLoadLibrary('cdejecter.dll');
|
||
GetVolumeInfo:= GetProcAddress(DLL, 'GetVolumeInfo');
|
||
DiscInfo:= GetVolumeInfo(WideChar(Dir[1]));
|
||
Result:= DiscInfo.diHasInfo;
|
||
FileSystemName:= DiscInfo.diFileSystem;
|
||
VolumeName:= DiscInfo.diVolumeName;
|
||
Serial:= DiscInfo.diSerial;
|
||
FreeLibrary(DLL);
|
||
end;
|
||
procedure CreateShortCut(ShortCutName, Parameters, FileName: string);
|
||
var ShellObject: IUnknown;
|
||
ShellLink: IShellLink;
|
||
PersistFile: IPersistFile;
|
||
FName: WideString;
|
||
begin
|
||
ShellObject:= CreateComObject(CLSID_ShellLink);
|
||
ShellLink:= ShellObject as IShellLink;
|
||
PersistFile:= ShellObject as IPersistFile;
|
||
with ShellLink do
|
||
begin
|
||
SetArguments(PChar(Parameters));
|
||
SetPath(PChar(FileName));
|
||
SetWorkingDirectory(PChar(extractfilepath(FileName)));
|
||
FName:= ShortCutName;
|
||
PersistFile.Save(PWChar(FName), False);
|
||
end;
|
||
end;
|
||
function GetDesktopDir: string;
|
||
var reg: TRegistry;
|
||
begin
|
||
Result:= '';
|
||
reg:= TRegistry.Create(KEY_READ);
|
||
try
|
||
reg.RootKey:=HKEY_CURRENT_USER;
|
||
if reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', false) then
|
||
Result:= IncludeTrailingBackslash(reg.ReadString('Desktop'));
|
||
reg.CloseKey;
|
||
finally
|
||
reg.Free;
|
||
end;
|
||
end;
|
||
procedure UpdateLanguage;
|
||
var LNGFile: String;
|
||
begin
|
||
//Application.Title:= GetLocalStrA(0);
|
||
with cde_Main do
|
||
begin
|
||
//Caption:= GetLocalStrA(0);
|
||
//DriveListLbl.Caption:= GetLocalStrA(1);
|
||
//UpdateListBtn.Caption:= GetLocalStrA(2);
|
||
//EjectNowBtn.Caption:= GetLocalStrA(3);
|
||
//CreateLinkForEjectBtn.Caption:= GetLocalStrA(4);
|
||
//LNGFile:= GetCDEPath + 'language\' + GetLanguage + '.lng';
|
||
//LanguageNameLbl.Caption:= Format(GetLocalStrA(5), [INIReadString('lng_about', 'lng_name', 'default', LNGFile)]);
|
||
//LanguageTranslatorLbl.Caption:= Format(GetLocalStrA(6), [INIReadString('lng_about', 'lng_author', 'Alexander Babaev', LNGFile)]);
|
||
//LanguageVersionLbl.Caption:= Format(GetLocalStrA(7), [INIReadString('lng_about', 'lng_vers', '1.0', LNGFile)]);
|
||
//ChangeLanguageBtn.Caption:= '&' + GetLocalStrA(8);
|
||
//HomePageBtn.Caption:= GetLocalStrA(10);
|
||
//LanguageBox.Caption:= GetLocalStrA(23);
|
||
end;
|
||
with Ch_language do
|
||
begin
|
||
//Caption:= GetLocalStrA(8);
|
||
//OkBtn.Caption:= GetLocalStrA(9);
|
||
end;
|
||
with cde_LinkCreatorFrm do
|
||
begin
|
||
//Caption:= GetLocalStrA(24);
|
||
//DrivesBoxLbl.Caption:= GetLocalStrA(25);
|
||
//AddDriveBtn.Caption:= GetLocalStrA(26);
|
||
//RemoveDriveBtn.Caption:= GetLocalStrA(27);
|
||
//CreateLinkBtn.Caption:= GetLocalStrA(28);
|
||
//CancelBtn.Caption:= GetLocalStrA(29);
|
||
end;
|
||
with cde_DriveAdderFrm do
|
||
begin
|
||
//Caption:= GetLocalStrA(30);
|
||
//SelectBtn.Caption:= GetLocalStrA(31);
|
||
//CancelBtn.Caption:= GetLocalStrA(32);
|
||
end;
|
||
end;
|
||
function ShowMessageBox (const AText: string; const AMessageType: Longint; const AMessageBtns: Longint = 0): integer;
|
||
begin
|
||
MessageBeep(AMessageType);
|
||
Result:= Application.MessageBox(pchar(AText), pchar(Application.Title), AMessageType + AMessageBtns);
|
||
end;
|
||
procedure CreateDriveRec (const ADrive: WideChar);
|
||
var DiscFrame: Tcde_disc_frm;
|
||
begin
|
||
DiscFrame:= Tcde_disc_frm.Create(cde_Main);
|
||
with DiscFrame do
|
||
begin
|
||
Parent:= cde_Main.WorkArea;
|
||
Align:= alTop;
|
||
Drive:= ADrive;
|
||
UpdateDriveInfo;
|
||
end;
|
||
end;
|
||
end.
|