When there is a need to configure a shortcut created by an Inno Setup installation package, the approach mentioned in the topic “How to set ‘Run as administrator’ on a file using Inno Setup” (URL here: How to set ‘Run as administrator’ on a file using Inno Setup) is widely used.
Unfortunately, this approach does not work in Inno Setup 6.3, as the procedure SetElevationBit encounters an AccessViolation error. The issue is that there is a bug in the TStream.Seek method in this version of Inno Setup.
Fortunately, the call to the Seek method can be replaced by using the Position property, which allows us to work around the issue until it is fixed in Inno Setup.
The working version of the SetElevationBit method looks like this:
procedure SetElevationBit(AFilename: string);
var
LBuffer: string;
LStream: TStream;
begin
AFilename := ExpandConstant(AFilename);
Log('Setting elevation bit for ' + AFilename);
LStream := TFileStream.Create(AFileName, fmOpenReadWrite);
try
LStream.Position:= 21;
SetLength(LBuffer, 1);
LStream.ReadBuffer(LBuffer, 1);
LBuffer[1] := Chr(Ord(LBuffer[1]) or $20);
LStream.Position:= LStream.Position -1;
LStream.WriteBuffer(LBuffer, 1);
finally
LStream.Free;
end;
end;
I couldn’t respond to the original question due to the low reputation of my profile, so I had to create a new post 😉
Jaroslav Cap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.