/    Sign up×
Community /Pin to ProfileBookmark

How do we know whether a process is running or not

Hi All,
I have a standalone program where all the logic exists.
Now whenever due to some issues the program is restarted (It is in

middle of processing something),I need to save the data in this

abnormal condition to some text file or any other file.

The problem is how do i know that it is stopped.Is there any API in
Java which can help me to handle this condition.

Did anyone of you faced this kind of problem before.If so…please help
me.

Thanks in advance…

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@MadhurauthorAug 01.2007 — Do anyone of you used addShutdownHook(Thread hook) in java.lang.RunTime class.This is one of the solutions for this problem..

If you have any idea..please help..

Thanks in advance...
Copy linkTweet thisAlerts:
@Totte_chAug 24.2007 — I don't know if this can be this you mean...

[B]Main.java[/B]
[CODE]/**
* [descripción]
* Creado el 2/11/2005 @ 11:47:58 AM
*
* @author
* @version %I%, %G%
*/
public class Main {
public static void main(String[] args) {
System.out.println();
Process process = new Process(null, "MSN Messenger");
// WriteProcessMemory
if ( process.getpHandle() != 0 ) {
System.out.println("MSN Messenger encontrado!");
process.WriteProcessMemory(0x5070ED, new char[] {0x77EB});
} else {
System.out.println("Error: MSN Messenger no econtrado!.");
}
}
}[/CODE]

[B]Process.java[/B]
[CODE]/**
* [descripción]
* Creado el 31/10/2005 @ 09:46:47 PM
*
* @author
* @version %I%, %G%
*/
public class Process {
private int pHandle;
private static String NULL = "";

private native int OpenProcess(String lpClassName, String lpWindowName);
private native int WriteProcessMemory(int pHandle, int lpBaseAddress, char[] lpBuffer);
private native char[] ReadProcessMemory(int pHandle, int lpBaseAddress, int nSize);

static {
System.loadLibrary("SandBox");
}

public Process() {
}

public Process(int pHandle) {
this.pHandle = pHandle;
}

public Process(String lpClassName, String lpWindowName) {
this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName);
}

public int getpHandle() {
return pHandle;
}

public void setpHandle(int pHandle) {
this.pHandle = pHandle;
}

public void setpHandle(String lpClassName, String lpWindowName) {
this.pHandle = OpenProcess(lpClassName == null ? NULL : lpClassName, lpWindowName == null ? NULL : lpWindowName);
}

public int WriteProcessMemory(int lpBaseAddress, char[] lpBuffer) {
return WriteProcessMemory(pHandle, lpBaseAddress, lpBuffer);
}

public char[] ReadProcessMemory(int lpBaseAddress, int nSize) {
return ReadProcessMemory(pHandle, lpBaseAddress, nSize);
}
}[/CODE]

SandBox.dll
×

Success!

Help @Madhur spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...