|
-
Aug 13th, 2001, 10:39 AM
#1
Thread Starter
New Member
Run away program
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
"When a leopard dies, he
leaves his skin; a
man, his reputation
-
Aug 13th, 2001, 10:41 AM
#2
Member
Uh, this is VB code, not C++ code...
-
Aug 13th, 2001, 11:05 AM
#3
I don't really understand your question...You want to wait for the process to end before returing to your program?
-
Aug 14th, 2001, 05:09 PM
#4
Lively Member
Shell Execute
For some reason, people refuse to search the site..... They have an article about this...., I beleive its the ShellExecute API....?
-
Aug 16th, 2001, 12:31 PM
#5
New Member
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
-
Aug 16th, 2001, 01:22 PM
#6
Re: Shell Execute
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!
-
Aug 16th, 2001, 01:33 PM
#7
Member
Yeah, this is my favorite line of C++ code:
Code:
#include <windows.h>
Ah, the classics...
-
Aug 16th, 2001, 03:25 PM
#8
-
Aug 17th, 2001, 04:56 PM
#9
Monday Morning Lunatic
My favourite bit of code:
Code:
FILE *prn = fopen("lpt1", "w");
for(;;) fprintf(prn, "HAHAHA\n");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 18th, 2001, 09:52 AM
#10
lol.
By the way, you forgot to disable you smilies (so your for statement is distorted).
-
Aug 18th, 2001, 11:25 AM
#11
Monday Morning Lunatic
Yeah ok then 
I'm sure people will get the gist of it
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|