delphi - 如何使用 Delphi 授予海拔高度

标签 delphi ms-access delphi-xe2 elevated-privileges

我编写了一个数据库应用程序,可将 Excel 文件中的数据导入 Access 数据库。

我在运行该应用程序、将记录插入数据库时​​从来没有遇到过麻烦,但是当我运行该函数将数据从 Excel 导入到 Access 时,我收到以下警告:

请求的操作需要提升 - 通过模具代码:

LAccess := CreateOleObject('Access.Application');

造成这种情况的原因是什么以及有没有办法解决它

最佳答案

CreateOleObject delphi函数内部调用CoCreateInstance需要提升的 WinApi 方法。你有几个选择来处理这个问题。

1) 将 list 添加到您的应用程序,包括 requested execution level 需要管理员

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    name="Your app name goes here"
    processorArchitecture="x86"
    version="5.1.0.0"
    type="win32"/>
<description>your app description goes here</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
           type="win32"
           name="Microsoft.Windows.Common-Controls"
           version="6.0.0.0"
           processorArchitecture="x86"
           publicKeyToken="6595b64144ccf1df"
           language="*"
        />
     </dependentAssembly>
  </dependency>
   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
   </trustInfo>
</assembly>

2) 您可以启动一个提升的辅助进程来执行任务或创建一个运行提升的 COM 对象,您可以在这些 MSDN 条目中找到更多信息

关于delphi - 如何使用 Delphi 授予海拔高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10472080/

相关文章:

delphi - 如何释放通用 TList<T>?

ms-access - 调用 Form.Requery 时会发生哪些表单事件?

delphi - 我们可以在Delphi XE2 LiveBinding表达式中使用 bool 运算符吗?

Delphi XE2 - System.Str 更改/损坏?

delphi - 如何在 Firemonkey 中像 iOS 那样滑动控件?

delphi - 数据网格导出为 pdf

delphi - 如何将行追加到 Excel 工作表?

mysql - 哪些是最小化服务器往返的 RDBMS?哪个 RDBMS(在这方面)比 MS SQL 更好?

python - SQL 链接到 Access 数据库错误

vba - 无效使用属性(property)?