473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Registry Update

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
Jan 3 '08 #1
2 1716
J.K. Baltzersen wrote:
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.

[..]
This is not a language problem and as such it cannot be solved by means
of the Standard C++ language or library alone. Please use mechanisms
available to you in your OS (like an event or a mutex). Also, when
asking about OS-specific stuff, please refrain from posting to c.l.c++
since OS-specific questions are off-topic here. Thanks.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 3 '08 #2
J.K. Baltzersen wrote:
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.
Find another way. Vista won't let your software bother the registry.

Put your counter in a file. Read with lock, update the counter, put it back,
unlock the file.
Jan 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mark A | last post by:
Here is the description of a new feature in 8.2.2 (FP9) from the InfoCenter: "DB2_SKIPINSERTED registry variable You can use the DB2_SKIPINSERTED registry variable to skip uncommitted inserted...
2
by: Grant Schenck | last post by:
I have an Internet Explorer toolbar built with C# .Net. I'd need to install the GUID in HKLM\Software\Microsoft\Internet Explorer\Toolbars However, I can't find any way to get my setup project...
2
by: Ty Moffett | last post by:
Below is a set of insructions that changes the registry keys pertaining to Automatic Updates on my Windows XP box. I can make changes using the control panel applet and see the changes reflected...
3
by: Eric D. Anderson | last post by:
I'm writing a program in C and I am wondering if there is a way to write to the registry? For example, just to throw a line out there(cause its the only path I can think of off the top of my...
0
by: sxzy | last post by:
Hi, I use OpenRemoteBaseKey to open HKLM key on remote machine in same domain Code fails on OpenSubKey with error "Requested registry key is not allowed" I tried to give permissions to...
3
by: Dylan Parry | last post by:
Hi folks, I've just got a new machine at work, so I've spent all day copying across all of my work from my old machine. Now I've come across a problem that I've never seen before. I now get...
5
by: Anil Bakirci | last post by:
How can I update the registry, after i change a key value to take effect ? There is nothing usefull in Microsoft.Win32.Registry und Microsoft.Win32.RegistryKey. Wie kann man in .NET ein...
5
by: Prajaktaj | last post by:
Hi All, I want to update the registry. I have administrative rights so it works fine. But if i login as a normal user and not as an admin then it gives me an error as i dont have enough previleges....
0
by: Steve House | last post by:
I'm relatively new to VB 2005/2008 having done most of my work in VB6 and VBA. I'd like to deploy a VB 2008 project that doesn't need to be installed other than the controls in the GAC and the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.