unit OpDAOUsers;
interface
const
OptAllUsers = $1;
OptLoggedUsers = $2;
OptCorruptUsers = $4;
OptUserCount = $8;
OptUserAuthor = $b0b;
function GetUsers(
const _LDBFileName:
string; _opt: integer;
out _users:
array of string ): integer;
function GetError( _result: integer ):
string;
implementation
uses
ActiveX, Windows, SysUtils, Variants;
//Variants for later delphi versions
const
DLLName = '
MSLDBUSR.DLL';
function LDBUser_GetUsers( lpszUserBufferArray: PSafeArray;
const lpszFilename: TBStr;
nOptions: longint ): longint;
stdcall;
external DLLName;
function LDBUser_GetError( nErrorNo: longint ): TBStr;
stdcall;
external DLLName;
function GetUsers(
const _LDBFileName:
string; _opt: integer;
out _users:
array of string ): integer;
var
pfn: TBStr;
usr: variant;
i: integer;
p: ^pChar;
begin
pfn:= SysAllocStringByteLen(
nil, Length(_LDBFileName) + 1 );
try
StrCopy( pChar(pfn), pChar(_LDBFileName) );
usr:= VarArrayCreate( [Low(_users), High(_users)], varOleStr );
result:= LDBUser_GetUsers( @TVarData(usr).vArray, pfn, _opt );
if result > 0
then begin
p:= VarArrayLock( usr );
try
for i:= 0
to result - 1
do begin
_users[i]:= StrPas( p^ );
Inc( p );
end;
finally
VarArrayUnlock( usr );
end;
end {if ok};
finally
SysFreeString( pfn );
end;
end {GetUsers};
function GetError( _result: integer ):
string;
var
perr: TBStr;
begin
perr:= LDBUser_GetError( _result );
try
result:= StrPas( pChar(perr) );
finally
SysFreeString( perr );
end;
end {GetError};
end.