unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, System.StrUtils,
//CodeSiteLogging,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
JclSysInfo, JclFileUtils, JclShell;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DoCheckIfSomeProgramsAreInstalled(
const slPrograms, slResults: TStringList);
var
i, j: Integer;
sCommonStartmenuFolder, sStartmenuFolder:
string;
slShortcuts: TStringList;
ThisShellLinkRecord: JclShell.TShellLink;
ThisTargetExePath:
string;
begin
sCommonStartmenuFolder := JclFileUtils.PathAddSeparator(JclSysInfo.GetCommonStartmenuFolder);
sStartmenuFolder := JclFileUtils.PathAddSeparator(JclSysInfo.GetStartmenuFolder);
slShortcuts := TStringList.Create;
try
JclFileUtils.AdvBuildFileList(sCommonStartmenuFolder + '
*.lnk', faAnyFile, slShortcuts, amAny, [flFullNames, flRecursive]);
JclFileUtils.AdvBuildFileList(sStartmenuFolder + '
*.lnk', faAnyFile, slShortcuts, amAny, [flFullNames, flRecursive]);
for i := 0
to slShortcuts.Count - 1
do
begin
for j := 0
to slPrograms.Count - 1
do
begin
if Pos(slPrograms[j], AnsiLowerCaseFileName(ExtractFileName(slShortcuts[i]))) > 0
then
begin
JclShell.ShellLinkResolve(slShortcuts[i], ThisShellLinkRecord);
ThisTargetExePath := JclFileUtils.PathGetLongName(ThisShellLinkRecord.Target);
if CompareText('
.exe', ExtractFileExt(ThisTargetExePath)) = 0
then
begin
if Pos('
unins', AnsiLowerCaseFileName(ExtractFileName(ThisTargetExePath))) = 0
then
slResults.Add(ThisTargetExePath);
end;
end;
end;
end;
finally
slShortcuts.Free;
end;
end;
procedure CheckIfTheseProgramsAreInstalled(
const rgPrograms:
array of string);
var
i: Integer;
slPrograms: TStringList;
ProgramNames:
string;
slResults: TStringList;
begin
slPrograms := TStringList.Create;
slResults := TStringList.Create;
try
slResults.Sorted := True;
slResults.Duplicates := dupIgnore;
// ################################################
if Length(rgPrograms) = 0
then
begin
// Load lowercase! program names:
ProgramNames := PathAddSeparator(ExtractFilePath(Application.ExeName)) + '
ProgramNames.txt';
slPrograms.LoadFromFile(ProgramNames);
end
else
begin
for i := Low(rgPrograms)
to High(rgPrograms)
do
slPrograms.Add(rgPrograms[i]);
end;
// ################################################
Screen.Cursor := crHourGlass;
try
DoCheckIfSomeProgramsAreInstalled(slPrograms, slResults);
finally
Screen.Cursor := crDefault;
end;
// Ergebnis ausgeben:
//CodeSite.Send('slResults', slResults);
slResults.SaveToFile(PathAddSeparator(ExtractFilePath(Application.ExeName)) + '
Results.txt');
finally
slPrograms.Free;
slResults.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// Aufruf 1 (Laden der gesuchten Programme aus Textdatei):
CheckIfTheseProgramsAreInstalled([]);
// ODER Aufruf 2 (gesuchte Programme übergeben):
CheckIfTheseProgramsAreInstalled([
'
irfanview',
'
snagit 11 editor',
'
gimp',
'
microsoft clip organizer',
'
paint.net',
'
photoscape',
'
portrait professional',
'
serif photoplus',
'
tineye',
'
xnview',
'
image analyzer'
]);
end;
end.