I'm having a bit of an issue figuring out how to check how many times a process is running in windows. I have an existing Visual C++ Program that uses the open source application dtelnet to connect to a system.
We have modified it here at our company to create lock files for each session of dtelnet, thus allowing only 8 sessions to be open at a time.
We've got a similar utility in Linux for graphical workstations. The problem I'm seeing is that sometimes, the screen locks are not being removed, this is the case in Windows and Linux.
In linux, I wrote a simple bash script script to check how many times the process was running, and if it's the first instance, go ahead and clear out the lock files.
I'm looking for something similar in Windows and am having some trouble locating a fix for what I need.
I need to:
1) Check how many times the process dtelnet.exe is running.
2) If the process is running 1 time, then this is the initial process and let's go ahead and clear any screen lock files (names scr1 - scr8).
3) If the process is running more than 1 time, then it's not the first running, so don't clear any locks.
Admittedly, I am new to programming in Windows and with C++. I have done shell scripting, some perl, and some java. Any code snippets or examples would be greatly appreciated.
The existing program was compiled with Visual C++ 6.0 and I have this or Visual C++ 8.0 available to me.
I don't mind researching, and have been for a couple of days but have not had much luck finding a specific solution.
Thanks in advance.