runtime Error 740
lazarus / 12-Debugger
----------------------------------------------------------------------
cpicanco · 2016-12-17 14:37
On windows 10, after succefully compiling a program, the debugger
exits with a runtime error 740.
There is an error message that reads "Error 740: The requested
operation requires elevation", but this message was not shown, only
the number was shown.
Running the program outside Lazarus gives the error message : "A
referral was returned from the server".
Just right clicking and selecting Open as admin does not work.
I solved the problem by right clicking at the executable, selecting
properties and checking the box "Run as administrator". In Lazarus,
project options, the item "Require administrator" was selected in the
"Execution level" combo box. Error 740 persists when "as invoker" item
was selected. Error 740 persists when running Lazarus as admin (just
by right clicking and selecting open as admin, no checkbox...).
I am guessing that I am missing something here because the program
does not requires admin privilegies. It requires only network access
(libzmq.dll, with 14.0 vs toolkit, is a dependency).
So how to properly solve this issue?
----------------------------------------------------------------------
Thaddy · 2016-12-17 15:53
You need to define a rule for the windows firewall.
----------------------------------------------------------------------
cpicanco · 2016-12-17 17:10
Yes, I did setup a firewall rule. Error 740 persists without checking
the "run as admin" checkbox.
----------------------------------------------------------------------
Thaddy · 2016-12-18 07:03
Quote from: cpicanco on December 17, 2016, 06:10:05 pmYes, I did setup
a firewall rule. Error 740 persists without checking the "run as
admin" checkbox.
In that case:
Did you include a manifest resource? In that you can request
elevation.
https://msdn.microsoft.com/en-
us/library/windows/desktop/dn481241(v=vs.85).aspx
https://msdn.microsoft.com/en-
us/library/windows/desktop/aa374191(v=vs.85).aspx
If the user has sufficient rights on the network, then the privilege
level should probably be "AsInvoker".
The application will then inherit the rights of the user.
----------------------------------------------------------------------
cpicanco · 2016-12-22 14:40
Hi Thaddy, many thanks for your time. Do you know if the project
option "Include manifest file to enable themes" is the same manifest
you poited out? It was checked and the error persists.
----------------------------------------------------------------------
Badscales · 2023-01-11 11:38
Error 740 came out of the blue to spoil my Lazarus experience this
morning. It wouldn't go away... Every time I tried to run the
(splendid and magnificent!) software I had been testing and re-writing
successfully for a couple of weeks I was told by Lazarus that the
programme could not be made to run. In desperation, I eventually
tried double-clicking the newly-compiled version outside Lazarus. I
found I had to confirm that I wanted to allow my software to make
changes to the system before it would start my programme, which ran
(beautifully and perfectly - well, almost!) thereafter. To cut a long
story short, I had to invent another user for my computer, make
him/her/it an 'administrator' and demote myself from that exalted
status. Problem solved, and the solution might be worth trying, but
no guarantees!
----------------------------------------------------------------------
Thaddy · 2023-01-11 13:11
Is absolutely wrong and very bad advice. I gave the correct answer
above and many years ago (2016).
740 can only be caused by a missing or malformed manifest. All that is
explained above,
Simply study how manifest resources work. No need for administrator
rights.
so:
- A proper manifest file or resource (asInVoker, unless the
application needs access to other user accounts, then and only then
requireAdministrator - which is restricted to the application, not the
user!)
- Optionally a firewall rule, usually unlikely. when asInvoker
applies.
Additional remarks:
During debugging your own code you might use administrator rights, but
not for distribution.
Depending on the application, it may be the case that the application
is so intrusive or exposed it needs to be code signed.
The latter is unlikely in most normal cases.
And a very belated post script to cpicanco: That is indeed the same
manifest file, but you already knew that!
Usually this example manifest is enough:Code: XML
[Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
My App
You may
want to set uiAccess to true if applicable, usually not, along with
the application name and the platform in the correct places.
Adapt an existing manifest file to include all of the application
description part or simply replace or add the trust info part.
If your application has no manifest yet, the above should work
immediately.
Simplest way to test: save the above as .manifest in the same directory as your executable.
If it works, compile it into a resource file and include the rc in
your application. The resource constant is 24.
Note manifests are case sensitive, be aware of that.
A useful msdn entry is here: https://learn.microsoft.com/en-
us/windows/win32/sbscs/application-manifests?redirectedfrom=MSDN
----------------------------------------------------------------------
gfkat · 2023-01-17 08:52
In some case you just need to edit the configuration of the project
and configure the execution level to AsInvoker, see attachment.
----------------------------------------------------------------------
Thaddy · 2023-01-17 10:23
Quote from: gfkat on January 17, 2023, 09:52:06 amIn some case you
just need to edit the configuration of the project and configure the
execution level to AsInvoker, see attachment.
Correct.