Solved

One more question concerning GetModuleUsage

Posted on 1997-07-08
1
213 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now