Click to See Complete Forum and Search --> : Run away program
Jazzisam
Aug 13th, 2001, 10:39 AM
Currently I use a shell to exeute a program. Before it's done executing and creating the file the next line looks for that file and can't find it.
Can you help
1) Shell "c:\winnt\va.exe c:\" & dateT & "\Fablots.va"
2)Dim MySize
MySize = FileLen("c:\" & dateT & "\Fablots.dat")
If MySize <= 2 Then
MsgBox "No lots were found for the perameters you entered"
End If
filburt1
Aug 13th, 2001, 10:41 AM
Uh, this is VB code, not C++ code...
Megatron
Aug 13th, 2001, 11:05 AM
I don't really understand your question...You want to wait for the process to end before returing to your program?
TadaTensai
Aug 14th, 2001, 05:09 PM
For some reason, people refuse to search the site..... They have an article about this...., I beleive its the ShellExecute API....?
falafel
Aug 16th, 2001, 12:31 PM
Chuck this lot in a module and call ExecCmd.
It waits for the process to complete before returning control.
I cribbed it out of MSDN some time ago.
...
Option Explicit
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Public Sub ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the shelled application:
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
ret& = CloseHandle(proc.hThread)
End Sub
Megatron
Aug 16th, 2001, 01:22 PM
Originally posted by TadaTensai
For some reason, people refuse to search the site..... They have an article about this...., I beleive its the ShellExecute API....?
All the articles on this site are devoted to VB. Even though API is universal, it can be a bit cumbersome for a C programmer.
More importantly though, we all want things done fast! :)
filburt1
Aug 16th, 2001, 01:33 PM
Yeah, this is my favorite line of C++ code:
#include <windows.h>
Ah, the classics... :)
Megatron
Aug 16th, 2001, 03:25 PM
huh?
parksie
Aug 17th, 2001, 04:56 PM
My favourite bit of code:FILE *prn = fopen("lpt1", "w");
for(;;) fprintf(prn, "HAHAHA\n");
Megatron
Aug 18th, 2001, 09:52 AM
lol.
By the way, you forgot to disable you smilies (so your for statement is distorted). :)
parksie
Aug 18th, 2001, 11:25 AM
Yeah ok then :D
I'm sure people will get the gist of it ;) :p
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.