06-07-2006 03:47 PM
06-07-2006 07:35 PM
06-08-2006 03:50 AM
It is a thread/timing issue. At the point when you launch Wordpad, the OS will perform this in a separate thread to your program. This will likely take some time, as the OS has to find and load Wordpad.exe, which then has in turn has to go to the OS to find and load the file. Meanwhile, your program is still continuing to execute. In particular, your next steps are to re-open the debug file again - this will happen almost immediately, unless you are single-stepping when clearly the elapsed times involved are very much greater. So the net result is that, although CVI has let go of the file at the first fclose(), it has grabbed it again before Wordpad has had a chance to open it.
Do you need your program to carry on immediately after launching Wordpad? If not you could solve the problem by using system(), instead of LaunchExecutable(). If you only need Wordpad to view the file, instead of edit it, you could try using Notepad instead - this seems to be able to read a file that is still open by CVI, as long as you don't try to do a save operation.
JR
06-09-2006 09:06 AM
06-09-2006 01:41 PM
Try something like this...
int i = 0;
fclose(...);
SetBreakOnLibraryErrors (0);
while(LaunchExecutable(...) < 0)
{
Sleep(20); // windows sdk - windows.h
if(i++ > 100) // problem
break;
}
SetBreakOnLibraryErrors (1);