为了能运行我的程序,加入BDE。我做的安装程序把注册表中HKEY_LOCAL_MACHINE\SOFTWARE\Borland\BLW32中的 BLAPIPATH和LOCALE_LIB1的路径以及HKEY_LOCAL_MACHINE\SOFTWARE\Borland\Database Engine中的 CONFIGFILE01和DLLPath的路径都改成了我BDE文件的路径,这样我的程序运行是没有问题了。
但是其他程序用到BDE数据库接连的时候都会出现问题了,都会找不到数据库了。请问我应该怎么解决这个问题???
因为机器上本来就有BDE,如果我的安装程序不把BDE打包,我的程序可以正常运行吗?
但是其他程序用到BDE数据库接连的时候都会出现问题了,都会找不到数据库了。请问我应该怎么解决这个问题???
因为机器上本来就有BDE,如果我的安装程序不把BDE打包,我的程序可以正常运行吗?
解决方案 »
- 【bitxunmeng】生日快乐,希望你们能幸福!
- Delphi7检测到错误类 EAccessViolation,错误信息:'Access violation at address 0047D5C7 in module
- 急!!!dbgrideh合计行的问题
- 安装完Raize后编译出现错误!!!
- 关于应用服务器更新的问题!!!
- 乱编了一年多,刚知道自己什么也没有学到!
- 关于 五岳鑫 TW8VID 语音卡的问题
- 关于日期时间的问题,高分求教!
- 在IE中如何增加右键菜单,像NETANTS那样?
- 现在没斑竹啊.....怎么你们不当吗?
- 寻求合作;开发进销存软件
- 怎样在没有窗口的纯PASAL程序使用HOOK!?(有代码)
unit main;interfaceuses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
XPMan,
Registry, StdCtrls, ExtCtrls, ComCtrls;
const DataBaseName='desert'; //数据库别名
DataBaseFileName='db1.mdb'; //数据库名type
TMainForm = class(TForm)
Timer: TTimer;
pb: TProgressBar;
Label1: TLabel;
procedure TimerTimer(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function GetDir:String;
procedure CreateAccessODBC(MyAccess,Dir:String);
function GetSysDir:String;
end;var
MainForm: TMainForm;
created:Boolean=False;implementation{$R *.dfm}
function TMainForm.GetDir:String;
begin
Result:='';
Result:=ExtractFilePath(Application.ExeName);
if Result[Length(Result)]<>'\' then
Result:=Result+'\';
end;
function TMainForm.GetSysDir:String;
var
sDir:array[0..254] of char;
begin
GetSystemDirectory(sDir,255);
Result:=sDir;
if Result[Length(Result)]<>'\' then
Result:=Result+'\';
end;
procedure TMainForm.CreateAccessODBC(MyAccess,Dir:String);
var
registerTemp : TRegistry;
bData : array[ 0..0 ] of byte;
begin
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
//注册一个DSN名称
WriteString(MyAccess,'Microsoft Access Driver (*.mdb)')
else
//创建键值失败
begin
//MessageBox(Handle,'创建数据源失败,请您用管理账户登录后重试!','权限',MB_OK+MB_ICONSTOP);
exit;
end;
CloseKey; //找到或创建Software\ODBC\ODBC.INI\MyAccess,写入DSN配置信息
if OpenKey('Software\ODBC\ODBC.INI\'+MyAccess,True) then
begin
WriteString( 'DBQ',Dir);//数据库目录
WriteString( 'Description', 'Access数据库' );//数据源描述
WriteString( 'Driver',GetSysDir+'odbcjt32.dll' );//驱动程序DLL文件
WriteInteger( 'DriverId', 25 );//驱动程序标识
WriteString( 'FIL', 'Ms Access;' );//Filter依据
WriteInteger( 'SafeTransaction', 0 );//支持的事务操作数目
WriteString( 'UID', '' );//用户名称
bData[0] := 0;
WriteBinaryData( 'Exclusive', bData, 1 );//非独占方式
WriteBinaryData( 'ReadOnly', bData, 1 );//非只读方式
end
else//创建键值失败
begin
//MessageBox(Handle,'创建数据源失败,请您用管理账户登录后重试!','权限',MB_OK+MB_ICONSTOP);
exit;
end;
CloseKey; //找到或创建Software\ODBC\ODBC.INI\MyAccess\Engines\Jet
//写入DSN数据库引擎配置信息
if OpenKey('Software\ODBC\ODBC.INI\'+MyAccess+'\Engines\Jet',True) then
begin
WriteString( 'ImplicitCommitSync', 'Yes' );
WriteInteger( 'MaxBufferSize', 512 );//缓冲区大小
WriteInteger( 'PageTimeout', 10 );//页超时
WriteInteger( 'Threads', 3 );//支持的线程数目
WriteString( 'UserCommitSync', 'Yes' );
end
else//创建键值失败
begin
//MessageBox(Handle,'创建数据源失败,请您用管理账户登录后重试!','权限',MB_OK+MB_ICONSTOP);
exit;
end;
CloseKey;
Free;
end;
end;
procedure TMainForm.TimerTimer(Sender: TObject);
begin
if pb.Position<pb.Max then
pb.StepBy(2)
else
if created then
Application.Terminate
else
pb.Position:=0;
end;procedure TMainForm.FormActivate(Sender: TObject);
begin
Timer.Enabled:=True;
CreateAccessODBC(DataBaseName,GetDir+DataBaseFileName);
created:=True;
end;end.