?
Solved

Registry In Java

Posted on 2006-07-02
5
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Six Sigma Control Plans
Introduction to Processes

762 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