Es sollte funktionieren. Ein wenig Google und siehe da, hab noch was auf SO gefunden was eventuell Dir nützlich sein könnte.
Delphi-Quellcode:
uses ComObj,
ActiveX;
function IsObjectAvailable(
const ClassName:
string): Boolean;
var
ClassID: TCLSID;
begin
Result := Succeeded(CLSIDFromProgID(PWideChar(WideString(ClassName)),
ClassID));
end;
function IsObjectActive(
const ClassName:
string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
Result := False;
if Succeeded(CLSIDFromProgID(PWideChar(WideString(ClassName)), ClassID))
then
Result := Succeeded(GetActiveObject(ClassID,
nil, Unknown));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsObjectAvailable('
Excel.Application')
then
ShowMessage('
Excel is available');
if IsObjectActive('
Excel.Application')
then
ShowMessage('
Excel is running');
end;