Solved

Registry In Java

Posted on 2006-07-02
5
208 Views
Last Modified: 2010-04-17
I have created registry entry to restrict multiple Instances. I am removing registry entry when the program is closed using Runtime.getRuntime().addShutdownHook().

But if the application got hanged, and I terminated the application using task manager, the registry item will not be removed. How can I achieve this??
Also i want to remove the registry entry if the system got restarted abrupty when the program is running.

Thanks.
0
Comment
Question by:sree032397
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17028956
It would seem to me that a registry setting is insufficient to what you require;

If a program crashes - it by definition can not run any more code; because of this unless you have another application running to clean up after the first one this is very difficult to acheive.

You may be able to solve this if you either update the registry with a timeout value - and refreshed periodically by your application; so if another tries to open the registry then it can ignore values say > 30 min old

Or you can log the process id in the registry - with the name of the application; then you can simply test to see if the process id and the name of the app exist when a duplicate app tries to run - if they do not exist they can over-write these values.

As I mentioned above - if your code dies it can not do anything further; so can not delete these entries but you can enhance them to acheive the same end result.
0
 
LVL 1

Author Comment

by:sree032397
ID: 17029000
Ok,
Think I am looging the process in the registry,
If the process is terminated, then how can I Identify that such that I can remove it.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17029122
Use the API to find the process id - if it is not running - or has a different title; then remove the registry entry.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now