473,698 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1733
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
2912
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 rows for Cursor Stability (CS) and Read Stability (RS) isolation levels. The registry variables DB2_SKIPDELETED and DB2_EVALUNCOMMITTED are used to skip uncommitted deletions and uncommitted updates. Otherwise, CS and RS
2
3180
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 to do this for me... Does anyone know how to configure a setup project to update the registry? Thanks,
2
3113
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 via regedit.exe. However when I make the changes with the code below those changed are NOT reflected in the control panel applet even though they are actully being set. Does anyone have any experience with this?
3
1493
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 head)...if I wanted to write to "HKEY_CLASSES_ROOT\exefile\shell\open\command" how would I go about implementing it in my code ? -- Eric D. Anderson Information Technology
0
1416
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 everyone on that registry key, lowering all .NET 1.1 permissions to full trust and to no avail. The only thing that worked was: <identity impersonate="true"/>
3
18079
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 the following error when I attempt to run one of my sites: "Access to the registry key 'Global' is denied"
5
1345
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 Registry-Update machen ohne den Computer neuzustarten ? In Microsoft.Win32.Registry und Microsoft.Win32.RegistryKey konnte ich so was nicht finden.
5
3539
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. Please tell me that can i update registry without having administrative rights? Thanks for any help.
0
992
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 appropriate dotnet framework version, where the registry isn't updated. All I needed in Access was to update the mdb or update the exe in a VB6 project in the local directory. I already have a routine that looks for programs with a later...
0
9164
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8898
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.