Shell versus Modal

Private Sub mnuSauvDonn_Click()
'Save the database in the drive a:
'To save the .mdb, we must to close the database.

    rstProfil.Close
    rstCli.Close
    dbCli.Close

Shell "d:\pkzip\pkzip.exe a:\GesKaSyDo.zip d:\geskasydo\GesKaSyDo.mdb", vbHide

'The sub Ouverture reopen the database because the pgm. is not finished.

'My problem is here the sub OUVERTURE must to run only when the shell have finished to save the database, because the database is not saved if the database is reopen.
'I need something like a shell modal.
'Or where i must to reopen the database?

Ouverture
End Sub
LVL 1
dosylAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mark2150Commented:
Use the ExecCmd instead of SHELL. This will wait for the child to complete before continuing. Source code in "Code Snippets" section of my web page:

www.cyberchute.com/rvbus/madmark

M
0
mark2150Commented:
'
' These data type declarations are required to support the obscure windows
' function to spawn a child task and wait for it to finish before continuing
'
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
'
Const NORMAL_PRIORITY_CLASS = &H20&
Const INFINITE = -1&
'

Public Sub ExecCmd(cmdline$)
'
' This executes an external windows program and waits for it to complete
'
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:
'
holdhere:
    DoEvents
    ret& = WaitForSingleObject(proc.hProcess, 5000)
    If ret& <> 0 Then GoTo holdhere
'
ret& = CloseHandle(proc.hProcess)
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dosylAuthor Commented:
Mark2150, I want more Information. Your pgm. works but:
Where do you put vbHide or another one like in the shell, because i don't want the user see the window of the application.
If you can describe your variables in the Type and your functions i'd like that.
Can i remove some parts or i need all?

You can write to me at :
dosyl@sympatico.ca
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

dosylAuthor Commented:
Mark2150, I want more Information. Your pgm. works but:
Where do you put vbHide or another one like in the shell, because i don't want the user see the window of the application.
If you can describe your variables in the Type and your functions i'd like that.
Can i remove some parts or i need all?

You can write to me at :
dosyl@sympatico.ca
0
mark2150Commented:
You set the properties of the PROGRAM you're running. Set it to RUN MINIMIZED and CLOSE ON EXIT and it'll run with just a flicker down in the taskbar.

TYPE declares were lifted from MS page, I didn't write. They always work so I just leave 'em as is. No, I don't think you can remove much and expect it to continue to work.

M
0
dosylAuthor Commented:
Where do you set these properties? You don't have a page of properties in a Dos
program, and if it is a windows program how to access to the properties of a program that is not in my pgm. it is not a Form. How do you put Run Minimized and Close on exit?
0
mark2150Commented:
If you browse to *any* DOS program and right click it'll *create* a properties page automagically. Click on "program" tab and you're choices will be there!

M
0
dosylAuthor Commented:
Another question when i do what you writed, my pgm. become minimized too how to see always my pgm. when the .exe is running? I could to put a progress bar too, i believe.
0
dosylAuthor Commented:
MarkI250 don't answer to my last comment. The pgm. is minimized only in VB when it is a .exe the pgm. stays maximized.
0
mark2150Commented:
Ok, is there a Q in here? Where are we now?

M
0
dosylAuthor Commented:
No there is no question in the last comment, i answer to the previous comment.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.