![]() |
C++ / VBA question
So i have a executable written in C++, and i wish to call this executable in Visual Basic, and be able to read results from running the C++ program.
The C program outputs its results in a text file when it's done running. So my question is, how do I check, from Visual Basic for Applications, that the C program is done running? thanks. |
The shell command will work,but the program will continue executing as soon as the shell command is started.
shell "c:\program.exe" Also check this out: http://groups.google.com/groups?q=vi...ome.com&rnum=1 |
Have your program idle
and periodically check in to see if the file has been written and is available... put a special marker at the end of the file.... hopefully the file won't be to long. If it is going to be long then create a 2nd file @ completion and put the marker in there. Don't forget to implement reasonable timelimits and retries in case the C++ program fails.
There are options for making the two programs communicate... using .NET, you can basically import all the C++ code and convert the main into a function and simply return a data structure with the stuff you want. But getting .NET working isn't fun :-(. It is however the most elegant solution. I don't know all the other mechanism that exist for transferring data and objects between programs, but they exist. |
I think I will probably try the wait and check solution. I was already leaning towards this solution of having the C program generate a indicator text file when complete.
It doesn't have to be very elegant. Implementing my professor's reseach, so as long as it works reasonably well, it'll do. Problem is that I'm not familar with C++ and only somewhat competent in VBA. so I'm contented with relatively simple tricks here. |
ick no!!! :) software that periodcally checks for changes like this, bad, bad! :) loading regmon or filemon watching all those programs rabidly checking for registry or file changes is horrible.
even on a simple system, you are opening a can of worms. FindFirstChangeNotification, WaitForSingleObject etc implement semaphores, windows has some very powerful functions for talking between apps. http://msdn.microsoft.com arguably has the best technical docs/resources for any OS. afrer a few mins looking msdn i found this Code:
Example Program Then this http://support.microsoft.com/default...kb;en-us;96844 Code:
Private Declare Function GetModuleUsage% Lib "Kernel" _ |
All times are GMT -8. The time now is 08:08 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project