用installshield可以把DBE打包到安装程序中,就可以不用装DELPHI了。
关于ODBC配置,你用的是ACCESE的话,和nickylin的方法差不多,但应这样:
procedure Tfrlogo.FormCreate(Sender: TObject);
VAR
REG:TREGISTRY;
begin
REG:=TREGISTRY.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKey('Software/ODBC/ODBC.INI/ODBC Data Sources',True) then
reg.WriteString('WLGL','Microsoft Access Driver (*.mdb)')
else
begin
application.MessageBox('错误,不能创建ODBC数据源!','错误',mb_ok+mb_iconerror);
application.Terminate;
end;
reg.CloseKey;
if reg.OpenKey('Software/ODBC/ODBC.INI/WLGL',True) then
begin
reg.WriteString('DBQ',extractfilepath(application.ExeName)+'你的数据库.mdb');
reg.WriteString('Description','物料管理');
reg.WriteString('Driver',getwindir+'/System32/odbcjt32.dll');//getwindir是一个获得WINDOWS目录的函数!
reg.WriteInteger('DriverId',25);
reg.WriteString('FIL','MS Access;');
reg.WriteInteger('SafeTransactions',0);
reg.WriteString('UID','');
reg.CloseKey;
if reg.OpenKey('Software/ODBC/ODBC.INI/WLGL/Engines',true) then
begin
reg.CloseKey;
if reg.OpenKey('Software/ODBC/ODBC.INI/WLGL/Engines/Jet',true) then
begin
reg.WriteString('ImplicitCommitSync','');
reg.WriteInteger('MaxBufferSize',2048);
reg.WriteInteger('PageTimeout',5);
reg.WriteInteger('Threads',3);
reg.WriteString('UserCommitSync','Yes');
end
else
begin
application.MessageBox('错误,不能创建ODBC数据源!','错误',mb_ok+mb_iconerror);
application.Terminate;
end;
end
else
begin
application.MessageBox('错误,不能创建ODBC数据源!','错误',mb_ok+mb_iconerror);
application.Terminate;
end;
end
else
begin
application.MessageBox('错误,不能创建ODBC数据源!','错误',mb_ok+mb_iconerror);
application.Terminate;
end;
reg.CloseKey;
打包的时候可能要把ACCESSR的驱动一起打包,如果目录机器没有装OFFICE的话。
要打你的数据库放在同应用程序的同一目录下,如果不的话,上面的路径就要改!