从Delphi IDE启动时,什么会导致ShellExecuteEx因COMADMIN_E_REGDB_SYSTEMERR而失败?

时间:2014-03-01 20:05:51

标签: delphi delphi-xe2 com+ shellexecuteex

我有一个相当奇怪的问题:

我的程序使用ShellExecuteEx启动另一个程序。当我的程序独立运行时这很好用,但是从Delphi IDE启动它时失败,其中“从Delphi IDE启动”意味着:

  • 运行 - >运行(在调试器内)
  • 运行 - >无需调试即可运行

ShellExecuteEx返回false并且RaiseLastOsError导致以下错误消息:

System Error.  Code: -2146368396.
The COM+ registry database detected a system error.

同一个程序有另一个可能由同一问题引起的问题:TOpenDialog.Exeucte和TSaveDialog.Execute方法什么都不做。没有显示对话框,函数返回false。当程序单独运行时,这也可以正常工作。从谷歌搜索我发现这也是一个与COM有关的问题。

我的程序不包含任何COM代码,只包含Delphi RTL / VCL自动调用的那些函数。

我在CoInitialize和CoInitializeEx上放置了一个断点,发现只有一个来自ComObj.InitComObj的CoInitialize调用。那里似乎没有任何错误。

以下是失败的代码:

function ShellExecEx(const Filename: string; const Parameters: string;
  const Verb: string; CmdShow: Integer; _ShowAssociateDialog: Boolean = False): boolean;
var
  Sei: TShellExecuteInfo;
begin
  FillChar(Sei, SizeOf(Sei), #0);
  Sei.cbSize := SizeOf(Sei);
  Sei.FMask := SEE_MASK_DOENVSUBST;
  if not _ShowAssociateDialog then
    Sei.FMask := Sei.FMask or SEE_MASK_FLAG_NO_UI;
  Sei.lpFile := PChar(Filename);
  if Parameters <> '' then
    Sei.lpParameters := PChar(Parameters)
  else
    Sei.lpParameters := nil;
  if Verb <> '' then
    Sei.lpVerb := PChar(Verb)
  else
    Sei.lpVerb := nil;
  Sei.nShow := CmdShow;
  Result := ShellExecuteEx(@Sei);
end;

// called as:
lEditorFilename := 'C:\Program Files (x86)\Notepad++\notepad++.exe';
lParameterStr := '"D:\source\EditorUi.dfm" -n1540';
if not ShellExecEx(lEditorFilename, lParameterStr, '', SW_SHOWNORMAL) then
  RaiseLastOSError;

这是一个在Windows 8.1 64位上运行的32位Delphi XE2程序。

任何可能导致此问题的提示?

编辑:

根据David Heffernan关于env替换的问题,我删除了其他环境变量

LANG = DE

我已投入运行 - &gt;参数对话框用于测试德语翻译。突然间,上述两种效应都消失了。把它放回去,或只添加任何环境变量(例如test = test),可以可靠地再现它们。

WTF?

0 个答案:

没有答案