【发布时间】:2012-01-26 15:58:23
【问题描述】:
我的 windows7 32 位 PC(在 i3 上)遇到问题。我有 Outlook 2010 和 Delphi 7。 我正在使用以下代码来检测 Outlook 是否正在运行。
ClassID := ProgIDToClassID(ClassName);
Result := (GetActiveObject(ClassID, nil, Unknown) = S_OK);
这失败了,即结果变为错误,但在其他 PC 中这工作正常。
我得到的错误是 MK_E_Unavailable。
更新:
可能只是发生在我身上。
procedure TForm1.Button1Click(Sender: TObject);
function IsObjectActive(ClassName: string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
try
ClassID := ProgIDToClassID(ClassName);
Result := (GetActiveObject(ClassID, nil, Unknown) =S_OK );
except
Result := False;
end;
end;
begin
if IsObjectActive('Outlook.Application') Then
ShowMessage('OutLook is there.')
else
ShowMessage('OutLook is not there.')
end;
请注意 OL 正在运行并且
- 当我运行创建的 exe 时,我收到消息“OutLook is there”。
- 当我从 Delphi IDE 运行时,我收到消息“OutLook 不存在”。
这种情况总是会发生,我在 Windows 7 上使用 Delphi 7,以管理员身份运行。请告诉我为什么会发生这种情况以及我该如何解决。
Delphi 7 在 Windows 7 上的问题是什么。
请提出建议。
【问题讨论】:
-
首先要找出GetActiveObject返回的内容并解码HRESULT值
-
快速网络搜索表明这与完整性级别有关
-
你正式列出的错误意味着对象没有运行。
-
另外...从哪里你执行这段代码?定期申请?服务? ISAP dll?
-
我正在从 Delphi 7 执行上述代码,即它发生在我的开发机器中。
标签: delphi windows-7 outlook delphi-7