>Can anybody tell me how to set the password option on a Paradox table at
>run-time.
Here ya go... I can't vouch for the efficiency of the algorithm - it's passed though
too
many hands...
The parameter contains a stringlist of table names to secure... some other variables
are
used 'AliasPath' is either an alias or a path to the tables.
--
procedure TFrmDBAdmin.SecureThem(SL :TStrings);
var
TblDesc: CRTblDesc;
hDb: hDbiDb;
TablePath: array[0..dbiMaxPathLen] of Char;
TableCode: array[0..DBIMAXNAMELEN] of Char;
I :Integer;
TmpResult :DBiResult;
Password :String;
begin
if FrmDBAPass.ShowModal(Password)=MrOK then for I := 0 to SL.Count-1 do begin
LBMessages.Items.Add('Securing "'+SL[I]+'"...');
FillChar(TblDesc, SizeOf(CRTblDesc), 0);
StrPCopy(TablePath,AliasPath);
StrPCopy(TableCode,Password);
with TblDesc do begin
StrPCopy(szTblName, SL[I]);
StrCopy(szTblType, szParadox);
StrPCopy(szPassword,Password);
bProtected:=True;
end;
hDb := nil;
DbiOpenDatabase(nil, 'STANDARD', dbiReadWrite, dbiOpenExcl, nil,
0, nil, nil, hDb);
DbiSetDirectory(hDb, TablePath);
tmpresult := DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, FALSE);
DbiCloseDatabase(hDb);
if tmpresult<>0 then begin
if tmpResult=$2803 then
LBMessages.Items.Add('...Table in Use "'+SL[I]+'"')
else LBMessages.Items.Add(format('...Error $%4.0x',[tmpresult]));
end
else LBMessages.Items.Add('...Secured "'+SL[I]+'"');
Application.ProcessMessages;
end;
end;
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz