Inno Setup 制作的安装程序直接访问Access数据库

Inno Setup 灵巧的制作手法博得众多软件爱好者的喜爱,它提供的 Pascal 脚本动态执行功能更受大家关注和研究。以下是本人用Inno Setup的Pascal脚本实现在软件安装过程中即时访问Microsoft Access数据库的代码,供大家学习和参考。(以下代码仅含 [Code] 部分)

[Code]
procedure SaveSecureKey;
var
  AccessServer: Variant;
  RecordAffected: Integer;
begin
  try
    AccessServer := CreateOleObject ('ADODB.Connection');
  except
    RaiseException ('Failed to create ADODB object!');
  end;
 
  AccessServer.ConnectionString := Format (
    'Provider=%s;Data Source=%s%s;Persist Security Info=False;' +
    'Jet OLEDB:Database Password=123456',
    ['Microsoft.Jet.OLEDB.4.0', 'd:/temp/', 'data.mdb']);
  try
    AccessServer.Open;
    try
      AccessServer.Execute ('DELETE * FROM dic_SysParams');
      AccessServer.Execute (
        Format ('INSERT INTO dic_SysParams(Sp_SecureKey)' +
          'values (''%s'');', ['1234567890']));
    except
      RaiseException ('Failed to initialize secure key value!');
    end;

  finally
    AccessServer.Close;
  end;
end;
 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值