TheSwamp
Code Red => VB(A) => Topic started by: Amsterdammed on August 27, 2005, 07:59:27 AM
-
Hello,
I wrote some accounting program for our company; making it easy for drafters to put in on the end of the day what they were working on.
It starts a dialog with the BeginQuit event, reads log data out a text file, writes data with the user input added to excel sheets. In the end the txt file is deleted because the info is already stored.
Everything works fine, but there is one possible source of error: Having two Sessions of Autocad open at the same time and running the accounting dialog when closing the first session.
I know there is no reason for having two sessions running the same time, but we work with a HVAC application from a third party written in C++ and this software sometimes does strange moves.
Is there a simple way to find out if there is a second acadApp. Object running out there ?
Thanks in Advance,
Bernd
-
Convert > this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/taking_a_snapshot_and_viewing_processes.asp) < code to VB; something like > this (http://www.vbnet.mvps.org/index.html?code/system/toolhelpprocesses.htm) <.
:)
-
All you'd have to do is copy the code in Command1_Click Sub to a Public Function, called, let's see GetAcadAppCount and modify the logic in the do loop so that it tests the uProcess.szExeFile string for the inclusion of "acad.exe" (don't get tripped up by case or the additional info in the uProcess.szExeFile string) instead of pushing it to the listbox, talling and returning the number of instances found. I tried it and it worked fine under Windows XP, SP2; very easy stuff.
Might consider making it a generic function that takes one parameter, the name of the executable whose running instances you wish to tally.
I'd post my version but I'm honoring the author's wishes per his web site.
:)
-
Thanks Mike
I was out in the yard working on my boat, so it took a while till i read your helpfull post.
Of course I didn’t read it well enough in the first place (or not understood it) and got confused by the info attached to the string, but it works now.
I also will honour the author’s wish on his website.
Bernd :D
-
Good to hear it Bernd; thanks for checkin' back.