Solved

Registry In Java

Posted on 2006-07-02
5
210 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
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.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 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

20 Experts available now in Live!

Get 1:1 Help Now