Solved

One more question concerning GetModuleUsage

Posted on 1997-07-08
1
217 Views
Last Modified: 2008-03-06
Hi experts,

I have one more question concerning the "GetModuleUsage" API function.

With help of the "Shell" and "GetModuleUsage" (= API function)
command I want to start several times a math software which reads input from a text file and does some very time consuming calculations with this input data.

So far my source code has the following structure:

Private Sub btnEndCommand_Click()
Dim i%
For i = 0 To 3
result = Shell("my_math_program.exe " , 6)
While GetModuleUsage(result) > 0
DoEvents
Wend
Next
End Sub

This attempt unfortunately has one very big setback:

In my VB sample procedure the user has to stop and start INTERACTIVELY
the single my_math_program sessions.

Is it possible to use "GetModuleUsage" in a "non-interactive-mode", too?

I would like to let us say 3 calculations being done during the night while
I am sleeping.
So I don't want to get up after each session and finish/start each session
by mouse click.
I want that each calculation session is started and finished AUTOMATICALLY,
without my interaction. So the second call of my_math_program should be
done after the first calculation is finished, the third call should be done
after the second calculation is finished, and so on.
Unfortunately one doesn't know the needed time for each calculation before,
so it makes no sense to start the calulation sessions in a certain time
interval.

What else could I try, If "GetModulUsage" is not the appropriate idea to
solve my problem?

If it is a help for you experts, I can send you this math program. It is
freeware so it can be freely distributed.

Any suggestions are highly appreciated.

cu
Christian Mathes
0
Comment
Question by:mathes
1 Comment
 
LVL 2

Accepted Solution

by:
vorlon earned 50 total points
ID: 1428116
mathes,
Is you're math program an interactive application? I'm assuming it is not since it can run at night. In order for you're vb program to run you're math program several times, you can do a few things:

A) Create a loop in which:
1) you're math program gets executed
2) you're vb program checks for its termination using GetModuleUsage
3) you're vb program does some processing after the math program is done
4) go back to step 1

B) Instead of creating a closed loop with the above steps, place the above steps in a timer. Have the timer go off, say, every 5 minutes. Each time the timer event goes off, you could check the time from the system clock and therefore run the formentioned loop at predeterined times. Since you don't know what time to process, then it's better to maybe run the process every 5 minutes anyway.

QUESTION: Since you don't know what time to process the results of the math program, how do you determine when it's time run the vb program? All is dependent on that. The GetModuleUsage function is only usefull in determining when a certain application has terminated.

If you have any further questions don't hesitate to comment...
Hope this helps.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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