Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Registry In Java

Posted on 2006-07-02
5
Medium Priority
?
230 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn different types of Android Layout and some basics of an Android App.
Six Sigma Control Plans
Introduction to Processes

610 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