unit Unit1MergeMe;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, system.IOUtils, StdCtrls ;
type
TFormFIND =
class(TForm)
ListBoxtmp: TListBox;
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
OpenDialog1: TOpenDialog;
Button2: TButton;
OpenDialog2: TOpenDialog;
Button3: TButton;
// gtPDFDocument1: TgtPDFDocument;
// gtPDFDocumentCOVER: TgtPDFDocument;
ListBoxEnd: TListBox;
SaveDialog1: TSaveDialog;
Memo1: TMemo;
CheckBox1: TCheckBox;
//gtPDFDocument2: TgtPDFDocument;
CheckBox2: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
function GetTempDirectory:
String;
PROCEDURE GetComponentCaptions(frm:TForm; FN:
string);
public
{ Public-Deklarationen }
end;
var
FormFIND: TFormFIND;
mypath:
string;
implementation
{$R *.dfm}
uses UnitFGMain, Typinfo;
const
CSCaption = '
Caption';
procedure TFormFIND.Button1Click(Sender: TObject);
begin
if opendialog1.Execute
then
begin
edit1.Text:= Opendialog1.FileName;
end;
end;
function filenameconform(fn:
string):
string;
begin
fn:=stringreplace(fn,'
','
_',[rfReplaceall]);
fn:=stringreplace(fn,'
.','
_',[rfReplaceall]);
fn:=stringreplace(fn,'
:','
_',[rfReplaceall]);
result:=fn;
end;
procedure TFormFIND.Button3Click(Sender: TObject);
var
i: Integer;
mymergedfn:
string;
begin
savedialog1.filename:=format('
%sGREPFORM.pas',[mypath]);
if Savedialog1.execute
then
begin
for i := 0
to myforms.Count-1
do
begin
GetComponentCaptions(TForm(myforms[i]),savedialog1.filename);
end;
end;
end;
PROCEDURE Tformfind.GetComponentCaptions(frm: TForm ; FN:
string);
VAR
texts: TStringList;
comp: TComponent;
capt:
String;
i: Integer;
BEGIN
texts := TStringList.Create;
TRY
WITH texts
DO BEGIN
Duplicates := dupIgnore;
Sorted := True;
FOR i:=0
TO frm.ComponentCount-1
DO
begin
comp := frm.Components[i];
if comp
is TControl
then
begin
if IsPublishedProp(Comp, CSCaption)
then
begin
capt:=GetStrProp(Comp, CSCaption);
IF (comp.
Name <> '
')
AND
(capt <> '
')
THEN Add(comp.
Name+'
='+capt);
end;
end;
SaveToFile(FN)
end;
END;
FINALLY
texts.Free
END
END;
function TFormFIND.GetTempDirectory:
String;
var
tempFolder:
array[0..MAX_PATH]
of Char;
begin
//GetTempPath(MAX_PATH, @tempFolder);
//result := StrPas(tempFolder);
result:=TPath.GetTempPath;
end;
function ReportTime(
const Name:
string;
const FileTime: TFileTime):
string;
var
SystemTime, LocalTime: TSystemTime;
begin
if not FileTimeToSystemTime(FileTime, SystemTime)
then
RaiseLastOSError;
if not SystemTimeToTzSpecificLocalTime(
nil, SystemTime, LocalTime)
then
RaiseLastOSError;
result:=Name + '
: ' + DateTimeToStr(SystemTimeToDateTime(LocalTime));
end;
procedure GetBuildInfo(
var V1, V2, V3, V4: word);
var
VerInfoSize, VerValueSize, Dummy: DWORD;
VerInfo: Pointer;
VerValue: PVSFixedFileInfo;
begin
VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
if VerInfoSize > 0
then
begin
GetMem(VerInfo, VerInfoSize);
try
if GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo)
then
begin
VerQueryValue(VerInfo, '
\', Pointer(VerValue), VerValueSize);
with VerValue^
do
begin
V1 := dwFileVersionMS
shr 16;
V2 := dwFileVersionMS
and $FFFF;
V3 := dwFileVersionLS
shr 16;
V4 := dwFileVersionLS
and $FFFF;
end;
end;
finally
FreeMem(VerInfo, VerInfoSize);
end;
end;
end;
function GetBuildInfoAsString:
string;
var
V1, V2, V3, V4: word;
begin
GetBuildInfo(V1, V2, V3, V4);
Result := IntToStr(V1) + '
.' + IntToStr(V2) + '
.' +
IntToStr(V3) + '
.' + IntToStr(V4);
end;
procedure TFormFIND.FormCreate(Sender: TObject);
var
targetinfo:
string;
fad: TWin32FileAttributeData;
begin
if not GetFileAttributesEx(PChar(Application.ExeName), GetFileExInfoStandard, @fad)
then
RaiseLastOSError;
//ReportTime('Created', fad.ftCreationTime);
//ReportTime('Modified', fad.ftLastWriteTime);
//ReportTime('Accessed', fad.ftLastAccessTime);
{$IFDEF WIN64}
targetinfo:='
(x64 Architecture)';
{$ELSE}
targetinfo:='
Architecture: 32bit';
{$ENDIF}
targetinfo := targetinfo + format('
%s : %s',
[ReportTime('
Created', fad.ftCreationTime),
ReportTime('
Modified', fad.ftLastWriteTime)]) ;
FormFIND.Caption := FormFIND.Caption+'
- Build: ' + GetBuildInfoAsString + targetinfo;
end;
end.