c# - Differents process handles -
i'm trying check, when programme starts, if instance ever launch. if is, whould kill it.
i've code :
process[] processes = process.getprocessesbyname(path.getfilenamewithoutextension(assembly.getexecutingassembly().location)); while (processes.length != 0) { bool killed = false; foreach (process process in processes) { string filename; seek { filename = process.modules[0].filename; } grab (win32exception) { continue; } if ((filename == assembly.getexecutingassembly().location) && (process.handle != process.getcurrentprocess().handle)) { messagebox.show("test"); process.kill(); thread.sleep(500); killed = true; messagebox.show("test"); } } if (!killed) break; processes = process.getprocessesbyname(path.getfilenamewithoutextension(assembly.getexecutingassembly().location)); } the problem when compare 2 processes handle, when process checked programme instance, handles different.
have ever cope problem ?
compare processes id instead of handle.
c# .net process .net-assembly handle
No comments:
Post a Comment