Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delphi application has permissions issues. Why?

Delphi 2010

Windows 7 - 64 bit.

I have an app which is reasonably trivial. It is a database app. It starts, finds it's current directory, looks for a database file IN THAT DIRECTORY, opens it, and displays some data. It works fine on my dev computer. I take it to another computer, also Windows 7, 64 bit, and I get an error. (Specifically from the database library - Component Ace - saying that a column doesn't exist). I have to believe this is a generic access error. When I right click on the desktop icon, and choose RUN AS ADMINISTRATOR, it runs fine. I have not explicitly locked anything down. I am on the computer as the Admin user. It is Admin that has installed the app. I am trying to distribute this app to multiple people. The install routine I am using is InnoSetup. What type of permission problem as I running into?

For completeness sake, I am including the INNO SETUP.iss file. Thanks GS

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "DocAssist"
#define MyAppVerName "DocAssist 3.2"
#define MyAppPublisher "GS"
#define MyAppExeName "DocAssist.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{6F34D198-14A0-4398-8E82-34232956CC5B}
AppName={#MyAppName}
AppVerName={#MyAppVerName}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir=D:\Projects\DocAssist\DISTR
OutputBaseFilename=DocAssistV3Setup
Compression=lzma
SolidCompression=yes
AppCopyright=GS
VersionInfoVersion=3.2

[Languages]
Name: english; MessagesFile: compiler:Default.isl

[Tasks]
; Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons};

[Files]
Source: D:\Projects\DocAssist\DISTR\DocAssist.exe; DestDir: {app}; Flags: ignoreversion
Source: D:\Projects\DocAssist\DISTR\DocAssist.ABS; DestDir: {app}; Flags: ignoreversion
Source: D:\Projects\DocAssist\DISTR\StopWords.txt; DestDir: {app}; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
Source: DocAssist Version 3_2.pdf; DestDir: {app}; Flags: isreadme
; Add-in dll
Source: D:\Projects\DocAssist\DISTR\DocAssistCom.dll; DestDir: {app}; Flags: regserver
Source: D:\Projects\DocAssist\DISTR\gdiplus.dll;      DestDir: {app}; Flags: ignoreversion

[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}
Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe}
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon

[Run]
Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent


[Registry]
Root: HKLM; Subkey: SOFTWARE\DocAssist; ValueType: none; Permissions: admins-full; Flags: uninsdeletekey createvalueifdoesntexist;
Root: HKLM; Subkey: SOFTWARE\DocAssist; ValueType: string; ValueName: InstallDir; ValueData: {app}; Permissions: admins-full; Flags: uninsdeletekey createvalueifdoesntexist
like image 821
user1009073 Avatar asked Apr 26 '26 10:04

user1009073


1 Answers

You should not write to files in your program files directory. This has been deprecated since Windows 95, but starting with Windows Vista it has become more strict and writing there is not allowed by default, unless you are an administrator.

There are many other places you can write to, and App Data is a commonly used folder, as is My Documents. You can use the SHGetSpecialFolderLocation api to find the exact location of these special folders (because it ma differ per installation).

B.t.w. if you have to use the application directory, resort to Application.ExeName or ParamStr(0) rather than on the current directory.

like image 89
GolezTrol Avatar answered Apr 28 '26 23:04

GolezTrol