Dear all,
I have a counter in my Windows registry. Is there any way of ensuring
that it is updated by one process/thread at a time only.
One way of updating is retrieving the counter, incrementing it, and
then writing it back. However, when doing it like this and one has a
process A and B, one risks process A retrieving the counter, then
being interrupted by process B, which retrieves the counter,
increments it, and then writing the updated counter to the registry
before process A again takes over, incrementing the old counter and
writing it to the registry.
I am using RegCreateKeyEx, RegQueryValueEx, and RegSetValueEx.
The result can be that the counter is incremented by 1 only, whereas
the wanted result is to have it incremented by 2.
Is there a simple solution to this problem?
Any help will be greatly appreciated.
Thank you very much in advance.
Best regards,
J.K. Baltzersen