kqglcommon.pas

来自「考勤管理系统很有借鉴的饿意义」· PAS 代码 · 共 64 行

PAS
64
字号
unit KqglCommon;

interface

uses
  Windows, SysUtils, Registry, DB, DBGrids;

resourcestring
  conKqglDataFile = 'Data\Kqgl.mdb';

var
  EXEPath: string;  //主程序路径

function GetExePath: string;
function Create_ODBC_Access(const ODBCName: string): boolean;

implementation

function GetExePath: string;
begin
  Result := ExtractFilePath(ParamStr(0));
end;

function Create_ODBC_Access(const ODBCName: string): boolean;
var
  RegisterTemp : TRegistry;
  SystemPath: array [0..255] of char;
  StrSystemPath: string;
begin
  Result := False;

  RegisterTemp := TRegistry.Create;
  with RegisterTemp do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources', True) = False then
      CloseKey
    else
      begin
        WriteString(ODBCName, 'Microsoft Access Driver (*.mdb)');
        CloseKey;
        if OpenKey('Software\ODBC\ODBC.INI\' + ODBCName, True) then
        begin
          GetSystemDirectory(SystemPath, 255);
          StrSystemPath := SystemPath;
          StrSystemPath := Trim(StrSystemPath);

          WriteString( 'DBQ', EXEPath + conKqglDataFile );
          WriteString( 'Driver', StrSystemPath + '\odbcjt32.dll' );
          WriteInteger( 'DriverId', 25 );
          WriteString( 'FIL', 'MS Access;' );
          WriteInteger( 'SafeTransactions', 0 );
          WriteString( 'UID', '' );
          CloseKey;

          Result := True;
        end;
      end;
    Free;
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?