Sonnich Jensen
2011-11-29 11:43:57 UTC
Hi all
I once wrote about that, and someone mentioned it could be a thread
problem. Please explain.
Anyway, I have now found the exact line causing the problem:
Result := False;
EnterCriticalSection(HS_Registry_op);
reg := TRegistry.Create;
reg.LazyWrite := False;
try
reg.RootKey := HKEY_CURRENT_USER;
// open registry key and create it, if do not exist
if Reg.OpenKey(key + '\ProdData', True) then // *** <---- fails
here, returns false, key not created.
begin
This sub is not able to open and create the key after 2-3 days of
work. Yes it happens in a thread, there are ~11 of them but only this
one does it. Restarting the thread makes it work again.
Any ideas why this happens?
Sonnich
I once wrote about that, and someone mentioned it could be a thread
problem. Please explain.
Anyway, I have now found the exact line causing the problem:
Result := False;
EnterCriticalSection(HS_Registry_op);
reg := TRegistry.Create;
reg.LazyWrite := False;
try
reg.RootKey := HKEY_CURRENT_USER;
// open registry key and create it, if do not exist
if Reg.OpenKey(key + '\ProdData', True) then // *** <---- fails
here, returns false, key not created.
begin
This sub is not able to open and create the key after 2-3 days of
work. Yes it happens in a thread, there are ~11 of them but only this
one does it. Restarting the thread makes it work again.
Any ideas why this happens?
Sonnich