How to provide height with Delphi

I wrote a database application that imports data from an excel file into an Access database.

I never had problems running the application to insert records into the database, but as soon as I ran the function to import data from Excel into Access, I get the following warning:

The requested operation requires a mark - by code:

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

What causes this, and is there any way around it.

+6
source share
1 answer

CreateOleObject delphi function internally calls CoAreateInstance WinApi, which requires a raise. You have several options for solving this problem.

1) Adding a manifest to your application, including the requested requireAdministrator run 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) You can start an additional process with a higher level that will perform the task or create a COM object that works with a higher level, you can find more information in these MSDN entries

+8
source

Source: https://habr.com/ru/post/915025/


All Articles