Board index » off-topic » Check(DbiCloseCursor(HRes)) Hangs machine for restricted user

Check(DbiCloseCursor(HRes)) Hangs machine for restricted user


2004-11-04 06:20:55 PM
off-topic19
On Win 2K
SP4
BDE5.01
Hi all,
we have the following to check and reset a number of BDE settings.
However, when logged in as aa restricted user it hangs in the finally
section of either SetConfigParameter or ReadConfigParameter.
It just hangs and contsntly uses 99% CPU.
The restrticted user has been given rights to BDE directory and reg
settings.
Any ideas?
Many thanks
Anthony
 
 

Re:Check(DbiCloseCursor(HRes)) Hangs machine for restricted user

Sorry - here's the code
procedure InitialiseBDE;
begin
DBIInit(Nil);
end;
procedure FinaliseBDE;
begin
DBIExit;
end;
Function ReadConfigParameter(Param: string) : String;
{Read the BDE configuration according to the input param
Param takes the form of PATH;KEY e.g \SYSTEM\INIT\;MAXBUFSIZE}
var
hCur: hDBICur;
rslt: DBIResult;
Config: CFGDesc;
Path, Option: string;
Found: boolean;
begin
ShowMessage('Start Of "ReadConfigParameter"' + #13 + 'Param : ' + Param);
hCur := nil;
rslt := dbiInit(nil);
Found := False;
try
// DBIInit(Nil);
if Pos(';', Param) = 0 then
raise EDatabaseError.Create('Invalid parameter passed to function.There
must ' +
'be a semi-colon delimited sting passed');
Path := Copy(Param, 0, Pos(';', Param) - 1);
Option := Copy(Param, Pos(';', Param) + 1, Length(Param) -
Pos(';',Param));
Check(DbiOpenCfgInfoList(nil, dbiREADWRITE, cfgPERSISTENT,Pchar(Path),
hCur));
repeat
rslt := DbiGetNextRecord(hCur, dbiNOLOCK, @Config, nil);
if rslt = DBIERR_NONE then
begin
if StrPas(Config.szNodeName) = Option then
begin
Result := Config.szValue;
Found := True;
break;
end;
end
else
if rslt <>DBIERR_EOF then
Check(rslt);
until rslt <>DBIERR_NONE;
if Found = False then
raise EDatabaseError.Create(Param + ' entry was not found in
configuration file');
finally
ShowMessage('Start Of Finally "SetConfigParameter" before "if hCur <>
nil"');
if hCur <>nil then
Check(DbiCloseCursor(hCur));
ShowMessage('Middle Of Finally "SetConfigParameter" Line after
"Check(DbiCloseCursor(hCur))"');
// DBIExit;
end;
ShowMessage('End Of "ReadConfigParameter"' + #13 + 'Param : ' + Param);
end;
procedure SetConfigParameter(Param: string; Value: string);
{edits the BDE configuration according to the input param and value
settings.
Param takes the form of PATH;KEY e.g \SYSTEM\INIT\;MAXBUFSIZE}
var
hCur: hDBICur;
rslt: DBIResult;
Config: CFGDesc;
Path, Option: string;
Found: boolean;
begin
ShowMessage('Start Of "SetConfigParameter"' + #13 + 'Param : ' + Param +
#13 + 'Value : ' + Value);
hCur := nil;
rslt := dbiInit(nil);
Found := False;
try
DBIInit(Nil);
if Pos(';', Param) = 0 then
raise EDatabaseError.Create('Invalid parameter passed to function. There
must ' +
'be a semi-colon delimited sting passed');
Path := Copy(Param, 0, Pos(';', Param) - 1);
Option := Copy(Param, Pos(';', Param) + 1, Length(Param) -
Pos(';',Param));
Check(DbiOpenCfgInfoList(nil, dbiREADWRITE, cfgPERSISTENT,Pchar(Path),
hCur));
repeat
rslt := DbiGetNextRecord(hCur, dbiNOLOCK, @Config, nil);
if rslt = DBIERR_NONE then
begin
if StrPas(Config.szNodeName) = Option then
begin
StrPCopy(Config.szValue, Value);
Check(DbiModifyRecord(hCur, @Config, FALSE));
Found := True;
break;
end;
end
else
if rslt <>DBIERR_EOF then
Check(rslt);
until rslt <>DBIERR_NONE;
if Found = False then
raise EDatabaseError.Create(Param + ' entry was not found in
configuration file');
finally
ShowMessage('Start Of Finally "SetConfigParameter" before "if hCur <>
nil"');
if hCur <>nil then
Check(DbiCloseCursor(hCur));
ShowMessage('Middle Of Finally "SetConfigParameter" Line after
"Check(DbiCloseCursor(hCur))" and before "DBIExit"' );
DBIExit;
ShowMessage('End Of Finally "SetConfigParameter" Line after
"DBIExit"');
end;
ShowMessage('End Of "SetConfigParameter"' + #13 + 'Param : ' + Param + #13
+ 'Value : ' + Value);
end;
Function ConfigureAliases : Boolean;
//Reads initial alias setup information from a ini file which is created
during first setup by installer
var ini : TIniFile;
MainPath, PrivPath, NetPath : String;
begin
Result := False;
if FileExists(ExtractFilePath(Application.exename) + '\Aliases.ini') then
begin
Result := True;
ini := TIniFile.Create(ExtractFilePath(Application.exename) +
'\Aliases.ini');
with Ini do
try
MainPath := ini.readString('aliasdata', 'IFP', '');
// PrivPath := extractFilePath(application.exename) + '\PV';
NetPath := ini.readString('aliasdata', 'NETWORK', '');
finally
ini.free;
end;
with Session do
begin
if MainPath <>'' then
begin
if IsAlias('IFP') then
DeleteAlias('IFP');
AddStandardAlias('IFP', MainPath, 'PARADOX');
SaveConfigFile;
end;
PrivPath := '';//Not needed for IFP
if PrivPath <>'' then
begin
if IsAlias('PRIVATE') then
DeleteAlias('PRIVATE');
AddStandardAlias('PRIVATE', PrivPath, 'PARADOX');
SaveConfigFile;
end;
if (NetPath <>'') and (UpperCase(NetFileDir) <>UpperCase(NetPath))
then
SetConfigParameter(PARADOXNETDIR, NetPath);
end;
//cleanup the inifile after use
SysUtils.DeleteFile(extractFilePath(application.exename) +
'\Aliases.ini');
end;
end;
Function ConfigureBDESettings : Boolean;
//A true result means that the settings have change and the app should be
restarted
var WinPlat : TWindowsVersion;
begin
Result := False;
WinPlat := GetOSVer.GetOSVersion;
InitialiseBDE;
Result := ConfigureAliases; //Sets up Net dir and aliases
// Driver Init
if ReadConfigParameter(PARADOXBLOCKSIZE) <>'16384' then
begin
SetConfigParameter(PARADOXBLOCKSIZE,'16384');
Result := True;
end;
if ReadConfigParameter(PARADOXLANGDRIVER) <>'intl' then
begin
SetConfigParameter(PARADOXLANGDRIVER,'intl');
Result := True;
end;
if ReadConfigParameter(PARADOXLEVEL) <>'7' then
begin
SetConfigParameter(PARADOXLEVEL,'7');
Result := True;
end;
//System format
if ReadConfigParameter(LANGDRIVER) <>'intl' then
begin
SetConfigParameter(LANGDRIVER,'intl');
Result := True;
end;
if ReadConfigParameter(LOCALSHARE) <>'TRUE' then
begin
SetConfigParameter(LOCALSHARE,'TRUE');
Result := True;
end;
if ReadConfigParameter(MAXBUFSIZE) <>'4096' then
begin
SetConfigParameter(MAXBUFSIZE, '4096');
Result := True;
end;
if ReadConfigParameter(MAXFILEHANDLES) <>'96' then
begin
SetConfigParameter(MAXFILEHANDLES,'96');
Result := True;
end;
if ReadConfigParameter(MINBUFSIZE) <>'2048' then
begin
SetConfigParameter(MINBUFSIZE, '2048');
Result := True;
end;
if ReadConfigParameter(SHAREDMEMSIZE) <>'2048' then
begin
SetConfigParameter(SHAREDMEMSIZE,'2048');
Result := True;
end;
//only for NT,2k or XP
if (Pos('NT',WinPlat.Os)>0) or (Pos('2000',WinPlat.Os)>0) or
(Pos('XP',WinPlat.Os)>0) then
begin
if ReadConfigParameter(SHAREDMEMLOCATION) <>'0x5BDE' then
begin
SetConfigParameter(SHAREDMEMLOCATION,'0x5BDE');
Result := True;
end;
end;
//Dates and times
if ReadConfigParameter(FOURDIGITYEAR) <>'TRUE' then
begin
SetConfigParameter(FOURDIGITYEAR, 'TRUE');
Result := True;
end;
if ReadConfigParameter(MODE) <>'1' then
begin
SetConfigParameter(MODE, '1');
Result := True;
end;
if ReadConfigParameter(YEARBIASED) <>'FALSE' then
begin
SetConfigParameter(YEARBIASED,'FALSE');
Result := True;
end;
if ReadConfigParameter(TWELVEHOUR) <>'FALSE' then
begin
SetConfigParameter(TWELVEHOUR,'FALSE');
Result := True;
end;
FinaliseBDE;
end;
Function REV_ConfigureBDESettings : Boolean;
//A true result means that the settings have change and the app should be
restarted
var WinPlat : TWindowsVersion;
begin
Result := False;
WinPlat := GetOSVer.GetOSVersion;
InitialiseBDE;
Result := ConfigureAliases; //Sets up Net dir and aliases
// Driver Init
// if ReadConfigParameter(PARADOXBLOCKSIZE) <>'16384' then
begin
SetConfigParameter(PARADOXBLOCKSIZE,'16384');
Result := True;
end;
// if ReadConfigParameter(PARADOXLANGDRIVER) <>'intl' then
begin
SetConfigParameter(PARADOXLANGDRIVER,'intl');
Result := True;
end;
// if ReadConfigParameter(PARADOXLEVEL) <>'7' then
begin
SetConfigParameter(PARADOXLEVEL,'7');
Result := True;
end;
//System format
// if ReadConfigParameter(LANGDRIVER) <>'intl' then
begin
SetConfigParameter(LANGDRIVER,'intl');
Result := True;
end;
// if ReadConfigParameter(LOCALSHARE) <>'TRUE' then
begin
SetConfigParameter(LOCALSHARE,'TRUE');
Result := True;
end;
// if ReadConfigParameter(MAXBUFSIZE) <>'4096' then
begin
SetConfigParameter(MAXBUFSIZE, '4096');
Result := True;
end;
// if ReadConfigParameter(MAXFILEHANDLES) <>'96' then
begin
SetConfigParameter(MAXFILEHANDLES,'96');
Result := True;
end;
// if ReadConfigParameter(MINBUFSIZE) <>'2048' then
begin
SetConfigParameter(MINBUFSIZE, '2048');
Result := True;
end;
// if ReadConfigParameter(SHAREDMEMSIZE) <>'2048' then
begin
SetConfigParameter(SHAREDMEMSIZE,'2048');
Result := True;
end;
//only for NT,2k or XP
if (Pos('NT',WinPlat.Os)>0) or (Pos('2000',WinPlat.Os)>0) or
(Pos('XP',WinPlat.Os)>0) then
begin
// if ReadConfigParameter(SHAREDMEMLOCATION) <>'0x5BDE' then
begin
SetConfigParameter(SHAREDMEMLOCATION,'0x5BDE');
Result := True;
end;
end;
//Dates and times
// if ReadConfigParameter(FOURDIGITYEAR) <>'TRUE' then
begin
SetConfigParameter(FOURDIGITYEAR, 'TRUE');
Result := True;
end;
// if ReadConfigParameter(MODE) <>'1' then
begin
SetConfigParameter(MODE, '1');
Result := True;
end;
// if ReadConfigParameter(YEARBIASED) <>'FALSE' then
begin
SetConfigParameter(YEARBIASED,'FALSE');
Result := True;
end;
// if ReadConfigParameter(TWELVEHOUR) <>'FALSE' then
begin
SetConfigParameter(TWELVEHOUR,'FALSE');
Result := True;
end;
FinaliseBDE;
end;