【发布时间】:2015-03-24 08:35:30
【问题描述】:
我正在使用下面给出的相同方式使用 ShellExecute,在 Delphi7 中打开一个 txt 文件,它给我在模块 BORdbk70.dll 中的访问冲突。
不知道这个问题是什么?我在使用列表中添加了ShellApi。
//sAddr := 'www.google.com';
Above line does not gives any error but also not redirect to browser and
ShellExecute returns result as "5 = Windows 95 only: The operating system denied access to the specified file"
sAddr := 'c:\text\info.txt';
res := ShellExecute(Handle, nil, PChar(sAddr), nil, nil, SW_SHOW);
showmessage(inttostr(res));
【问题讨论】:
-
这是一个纯调试器问题。没什么好担心的。无论如何,您都不应该使用
ShellExecute,因为它不能正确报告错误。使用ShellExecuteEx。 -
FWIW,你不可能知道
ShellExecute确实返回了什么错误,因为你的代码忽略了返回值。 -
@DavidHeffernan - 谢谢大卫,但现在另一个问题出现了,它以前是如何运行的,然后突然开始表现得像这样。系统和/或代码也没有变化。我也访问过这个页面 - qc.embarcadero.com/wc/qcmain.aspx?d=11751
-
你说的是一个 >10 岁的 IDE。我想你只需要忍受它。至少,看看是否使用
ShellExecuteEx,无论如何这是一个更好的选择,以某种方式避免了这个问题。 -
@DavidHeffernan - 是的,没错 :)。因为当我以管理权限运行我的程序时,此功能已成功执行。问题仅与您提到的调试有关。再次感谢。