I have a very old application written in delphi 5 running in some customers which uses the BDE. Now some users with Windows Vista and 7, had experimented some problems with the multiuser access. i' think which these problems are related to the location of the net
.and .lck
files. so the question is which is the proper way to confgure the BDE
under Windows Vista and 7 to avoid permissions and UAC conflicts?
In addition to the above answer, you'll want to make sure that the .net and .lck files are located in a user-specific directory under Windows 7, specifically:
C:\Users\{User Name}\AppData\Local\{Your Company Name}\{Your Application Name}
Those are the only folders that the current user will always have complete control over.
You can get this folder by using this code:
CSIDL_LOCAL_APPDATA = $001C;
function GetAppDataDirectory: AnsiString;
var
TempBuffer: array[0..MAX_PATH] of AnsiChar;
ResultLength: Integer;
begin
FillChar(TempBuffer,((MAX_PATH+1)*SizeOf(AnsiChar)),0);
ShlObj.SHGetSpecialFolderPathA(0,@TempBuffer,CSIDL_LOCAL_APPDATA,False);
ResultLength:=StrLen(pAnsiChar(@TempBuffer));
SetLength(Result,ResultLength);
Move(TempBuffer[0],pAnsiChar(Result)^,(ResultLength*SizeOf(AnsiChar)));
end;
and then appending {Your Company Name}
and {Your Application Name}
to the value returned. You'll need to include the ShlObj unit.
One such thing I remember is to configure the Session to put that kind of files on folders where a normal user have write-privileges.
From what I remember, the properties
Session.PrivateDir
Session.NetFileDir
Are the relevant ones.
The correct location will depend on concurrent access, the database you're connecting to, data location –in case of paradox or dbf's– and if you use cached updates or not.
I maintain an application written originally in D4, now compiled with D2007 when rarely needed and it works well on vista+ using this with it's particular configuration and needs (no paradox/dbf's).
If you don't want to work around the security bugs in a default install of the BDE (as other answers mention - granting permissions that the BDE installer forgot to), you can just run your application as an administrator.
You have a few options:
- Tell the user to right-click and select
Run As Administrator
every time. - Go to the program's Compatibility tab, and check
Run this program as an administrator
(which has the same effect as 1) - Go to the program's Compatibility tab, and
Run this program in compatibility mode
forWindows XP
(which has the same effect as 2) - Create a manifest
MyApp.exe.manifest
and include therequestedExecutionLevel
ofrequireAdministrator
(which has the same effect as 3)
In other words: Your application, as it stands right now, requires administrative access to run - so just run it as an administrator.
On the other hand you can make a few simple changes and your application will no longer need to run as an administrator; you've made the world a better place for all humanity!
来源:https://stackoverflow.com/questions/5384006/bde-windows-7-and-uac