Wile E. Coyote wrote:1. Of course, this program needs GRFcodec. Problem is that my program is faster than GRFcodec. When I convert file, GRFcodec must be executed twice (I use Shell command) and converter is trying to execute other GRFcodec, but first is not executed. That confuses program. I fixed it by inserting empty DOO-LOOP, but is there any other way to stop program executing during Shell command? Or is is other way to call programs from command prompt?
Try using the following code:
Code: Select all
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
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&
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
Sub ExecCmd(CmdLine As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
' 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)
End Sub
Then just call
ExecCmd "command line" to use it.
Command sequence ... doesn't make any file.
You can't use pipes like that except from the command interpreter. Now then, with the example I gave you above, you could do this (untested!):
Code: Select all
' declare section
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const CREATE_ALWAYS = 2
Private Const FILE_ATTRIBUTE_NORMAL = &H80
' ...
Sub ExecCmd(CmdLine As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim hndl As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
hndl = CreateFile("c:\path\to\filename", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
If Hndl <> 0 Then
start.hStdOutput = Hndl
End If
' 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)
If Hndl <> 0 Then
CloseHandle(Hndl) ' you now have the output text in the file
End If
End Sub
3. I also have problem with package and deployment wizard. When I make installer, I can't install program. I use WIN XP. Is VB 6.0 compatible with WIN XP? Or maybe my VB is corrupted?
Possibly VB is corrupted. The VB PDW is a horrible thing anyway, don't use it. Just distribute your EXE file, most people have the VB6 runtimes.