BDE, Windows 7 and UAC

走远了吗. 提交于 2019-12-06 12:36:00

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:

  1. Tell the user to right-click and select Run As Administrator every time.
  2. Go to the program's Compatibility tab, and check Run this program as an administrator (which has the same effect as 1)
  3. Go to the program's Compatibility tab, and Run this program in compatibility mode for Windows XP (which has the same effect as 2)
  4. Create a manifest MyApp.exe.manifest and include the requestedExecutionLevel of requireAdministrator (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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!