All source code in Visual Basic Ask a Visual Basic Pro Discussion Forum Categories All jobs in Visual Basic
Shells,waits,close,before,continues,processin
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 5,128,645. lines
 Jobs: 275. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login





Latest postings for Visual Basic.
Click here to see a screenshot of this code!DMmessagbox
By Frank Donckers on 2/9

(Screen Shot)

The Laser - Entrance Exam Creator
By Le Chevalier on 2/8


Click here to see a screenshot of this code!WiiNi Metur
By Dimityr Ivanov on 2/8

(Screen Shot)

Simple traductor de archivos INI
By Miguel Angel Esquef on 1/28


Click here to see a screenshot of this code!Resistor Color Code
By Ferdinand Viray on 2/7

(Screen Shot)

Click here to see a screenshot of this code!Database - Student Reccord
By Ferdinand Viray on 2/7

(Screen Shot)

Click here to see a screenshot of this code!Online Text Based Winsock Crime Game | Mafia Game
By William Hughes on 2/7

(Screen Shot)

Click here to see a screenshot of this code!NZB Reader III
By Ed Wilk on 12/29

(Screen Shot)

Click here to see a screenshot of this code!Jobz Tracker
By Andy J Spry on 2/6

(Screen Shot)

Click here to see a screenshot of this code!Database - Student Reccord
By Ferdinand Viray on 2/6

(Screen Shot)

Click here to see a screenshot of this code!Resistor Color Code
By Ferdinand Viray on 2/6

(Screen Shot)

a simple program (database)
By Jenilyn Brena on 2/6


Click here to see a screenshot of this code!Multipass BILATERAL FILTER. (V3.3)
By reexre on 1/12

(Screen Shot)

Click here to see a screenshot of this code!Completely hide taskbar in vista and seven.
By Alexander G on 2/5

(Screen Shot)

Binding DataGrid to ADODC
By kývanç ; on 2/5


Book Record
By kývanç ; on 2/5


VB6 to VB.NET Guide
By brandon teoh on 2/5


Easy dsr datareport
By Manuel Matamoros on 2/4


Click here to see a screenshot of this code!Manual RAID 1 v2.0.11
By Mike Morrow on 1/11

(Screen Shot)

Rotate Text Pure Vb, No Dll, No Api
By ivan pausich on 2/4


Click here to see a screenshot of this code!MediaVusion; A Powerful Media Player
By xvader on 2/4

(Screen Shot)

Click here to see a screenshot of this code!PSC Zip Store and read
By Kenneth Foster on 2/3

(Screen Shot)

Click here to see a screenshot of this code!Linear Power Supply Designer
By RandyT_CS on 2/3

(Screen Shot)

retrieve (get) all system services
By milad ghafooreyan on 2/3


Click here to see a screenshot of this code!easy inventory manager
By ravi vaghela on 2/3

(Screen Shot)

Click here to see a screenshot of this code!A simple Calculater in Vb 6
By Varun Naharia on 2/2

(Screen Shot)

Click here to see a screenshot of this code!Special Folder Locator
By dreamvb on 2/2

(Screen Shot)

Click here to see a screenshot of this code!material viewer system
By Donald Paras on 2/2

(Screen Shot)

Click here to see a screenshot of this code!Solid Lathe Simulation
By Eduardo Capatto Júnior on 2/1

(Screen Shot)

Click here to see a screenshot of this code!A simple Calculater in Vb 6
By Varun Naharia on 1/31

(Screen Shot)

Click here to see a screenshot of this code!Final Fantasy 3D game
By Yazan Markabi on 1/31

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

fWait

Print
Email
 
VB icon
Submitted on: 2/15/2000
By: Brian Cidern 
Level: Advanced
User Rating: By 11 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 26498 times.
 
(About the author)
 
     Shells an app, then waits for that app to close before it continues processing.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

'**************************************
'Windows API/Global Declarations for :fW
'     ait
'**************************************
Const PROCESS_ALL_ACCESS& = &H1F0FFF
Const STILL_ACTIVE& = &H103&
Const INFINITE& = &HFFFF


Private Declare Function GetWindowsDirectory _
    Lib "kernel32" _
    Alias "GetWindowsDirectoryA" ( _
    ByVal lpBuffer As String, _
    ByVal nSize As Long _
    ) As Long


Private Declare Function OpenProcess _
    Lib "kernel32" ( _
    ByVal dwDesiredAccess As Long, _
    ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long _
    ) As Long


Private Declare Function WaitForSingleObject _
    Lib "kernel32" ( _
    ByVal hHandle As Long, _
    ByVal dwMilliseconds As Long _
    ) As Long


Private Declare Function GetExitCodeProcess _
    Lib "kernel32" ( _
    ByVal hProcess As Long, _
    lpExitCode As Long _
    ) As Long


Private Declare Function CloseHandle _
    Lib "kernel32" ( _
    ByVal hObject As Long _
    ) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: fWait
' Description:Shells an app, then waits 


'     for that app to close before it continue
    '     s processing.
' By: Brian Cidern
'
' Inputs:None --
'
' Returns:Shelled app exit code
'
' Assumes:Pseudo code:
Uses API To Get the OS dir (for 95/98/NT4/2000 compatability) and appends result With Notepad.exe. Shells Notepad, returning process id. fWait gets the app hdl and issues a Do Events until the Exit code of the app <> STILL_ACTIVE&. When app is closed, a cheezy MsgBox displays.
Create a Std EXE. Add a command button, and use the default name (Command1).
'
' Side Effects:None --
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=6071&lngWId=1'for details.'**************************************



Private Sub Command1_Click()

Dim sCmdLine As String Dim idProg As Long, iExit As Long sCmdLine = fGetWinDir & "\notepad.exe" idProg = Shell(sCmdLine) iExit = fWait(idProg) If iExit Then MsgBox "Something very, very bad just happened." Else MsgBox "Finished processing Notepad." End If
End Sub
Function fWait(ByVal lProgID As Long) As Long
' Wait until proggie exit code <> ' STILL_ACTIVE& Dim lExitCode As Long, hdlProg As Long ' Get proggie handle hdlProg = OpenProcess(PROCESS_ALL_ACCESS, False, lProgID) ' Get current proggie exit code GetExitCodeProcess hdlProg, lExitCode Do While lExitCode = STILL_ACTIVE& DoEvents GetExitCodeProcess hdlProg, lExitCode Loop
CloseHandle hdlProg fWait = lExitCode End Function
Private Function fGetWinDir() As String
' Wrapper to return OS Path Dim lRet As Long, lSize As Long, sBuf As String * 512 lSize = 512 lRet = GetWindowsDirectory(sBuf, lSize) fGetWinDir = Left(sBuf, InStr(1, sBuf, Chr(0)) - 1) End Function


Other 3 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/23/2000 6:47:24 AMfiach

Does this program allow command line
arguments & outpurt redirection?
i.e text.exe arg1 > fileout.txt
(If this comment was disrespectful, please report it.)

 
2/23/2000 8:53:40 AMBrian Cidern

This was a request from a friend who needed to process a batch app before parent continued. You could however build your shell command line to include args and pass in to the function, assuming your shelled app accepts args. As far as the redirection, I don't think so. You'd have to trap the child output in the parent process and manipulate it from there. Unless, of course, the child process is a script, you could handle the redirection from the script.

(If this comment was disrespectful, please report it.)

 
2/23/2000 2:10:15 PMAndy

Praise Jesus! There are a couple of other examples on the site that DON'T work, but this one does and it's so streamilned and so slick. Nice submission, now I can complete my project the RIGHT way!
(If this comment was disrespectful, please report it.)

 
3/6/2000 6:00:38 PMCosmo

I get Sub or Function not found for;
(If this comment was disrespectful, please report it.)

 
5/26/2000 3:35:30 AMAlex

Thanx for this code. I like things that just work.
Easy to integrate and use.
Good job!
(If this comment was disrespectful, please report it.)

 
6/1/2001 10:40:08 AMMrGTI

Works nice. I just added a vbNormalFocus to the shell line to make it pop up instead of being minimized.

Good work!
(If this comment was disrespectful, please report it.)

 
7/30/2001 5:32:00 AMTroy

Excellent code, worked as advertised! This was exactly what I needed and dropped right in. Thanks!
(If this comment was disrespectful, please report it.)

 
7/22/2002 7:22:35 PMCrZ

Believe it or not, this code has save my job
(If this comment was disrespectful, please report it.)

 
12/29/2002 3:18:15 PMRandy Girard

Ok, this is IGSACTLY what I need... but it says that 2 of the functions aren't found... I'm guessing u didn't include the api declartions and junk :-P Can u help me plz and let me know where I can get them or just paste them here :-P
(If this comment was disrespectful, please report it.)

 
12/29/2002 3:20:24 PMRandy Girard

or maybe it was 3, or something... not really payin attention. my e-mail is Unho1yang1@hotmail.com if someone has the code. Thx
(If this comment was disrespectful, please report it.)

 
2/17/2003 3:14:12 AMDmitry Kirsanov

The missing API declaration:

Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

(If this comment was disrespectful, please report it.)

 
2/17/2003 3:18:24 AMDmitry Kirsanov

Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long

(If this comment was disrespectful, please report it.)

 
2/17/2003 3:19:37 AMDmitry Kirsanov

Haha :)))

Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

(If this comment was disrespectful, please report it.)

 
2/17/2003 4:02:08 AMDmitry Kirsanov

Another thing to add -
Const PROCESS_ALL_ACCESS = &H1F0FFF
(If this comment was disrespectful, please report it.)

 
4/7/2003 2:03:28 PMRandy Girard

hmmm...
I'm a dumbass. I get code from here all the time and never noticed the "copy-and-paste friendly version.." Link.

Anyway, I can't use the vb function shell for what I'm writing. I know y, but can't really explain it. ShellExecute gets what I need done, there is just 1 small problem... it doesn't return the procid :-\

If someone knows of a function that does what shellexecute does, but that also returns the ProcID, plz let me know.

my e-mail is Unho1yAng1@hotmail.com
(If this comment was disrespectful, please report it.)

 
8/10/2003 5:04:37 PM

i get an error on

Do While lExitCode = STILL_ACTIVE&

STILL_ACTIVE& Not defined.

(If this comment was disrespectful, please report it.)

 
10/2/2004 3:09:28 AMJeroen van de Ven

What does Something very bad just happend mean? I get that...
(If this comment was disrespectful, please report it.)

 
6/7/2005 6:23:16 AMD. HANIB

Dmitry Kirsanov

Did'nt you see the Win API declaration obove the code ?..;o)
All functions and constant were declared...

I have copied all the declarations and th fucntion in a class and it worked very fine without problem..
I'v just put an error gestion when the program shelled is not found..
An now here it'is a class Cls_ShellExecute with in a proc 3 parameters : CmdLine , Win aspect of the program lauched et WaitForEndProg boolean

Thanks Brian

*****

Driss
(If this comment was disrespectful, please report it.)

 
6/25/2005 6:55:16 AMAdam Kachwalla

always put the option explicit in the begining of your code
(If this comment was disrespectful, please report it.)

 
10/11/2005 8:58:46 AMIvo Smits

Auch.. loops that take longer than 1 sec should at use Sleep to wait at least 1 msec, to give other processes some time to do their job, and in this case, there is no need for DoEvents.
(If this comment was disrespectful, please report it.)

 
1/23/2007 11:43:32 PMB.Cem HANER

Thank you.
Really good
(If this comment was disrespectful, please report it.)

 
7/2/2009 7:00:33 AMTankut SAZLI

Thanks.
But ý'm not run this code in your project.Whats the problem?
code:
ShellExecute 0, "", "VirtualDubMod.exe", "/r /s""removedual.vcf"" /x", "", 1
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.