Solved

VB4: "Winoldap" and "Shell"

Posted on 1997-08-24
4
280 Views
Last Modified: 2012-08-13
Hi all,

I wrote a program under VB4/Win95. The major purpose of this program is to call DELTREE.EXE and XCOPY32.EXE so it's quite a simple program.
However, after the program executed, another program "Winoldap" left in the memory (I check it my pressing Crtl+Alt+Del). It will left one "Winoldap" onces my program execute. The "Winoldap" let my PC refuse to reboot and I have to shut down the "Winoldap" before I can reboot it.
Could someone solve it or give me further suggestion?

And how can I know when the "SHELL" command finished?

Thanks.
Arthur.
0
Comment
Question by:kcyeung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:vmpn
ID: 1432070
Oldapp is started when you call DELTREE or XCOPY.
0
 

Accepted Solution

by:
idek1 earned 50 total points
ID: 1432071
Ok put these 3 functions in the declarations:

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Then where you call your Shell statement use:

dim pid as long
dim handle as long
' Start the shelled application:
pid = Shell("Deltree blah blah", 1) ' also try ,0
handle = OpenProcess(&H100000, 0, pid)
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(handle,&HFFFFFFFF) ' wait to finish
ret& = CloseHandle(handle) ' this one closes the shell window

I don't know if this method works with 16bit Windows Applications though.

0
 

Author Comment

by:kcyeung
ID: 1432072
Thanks Idek1,

The SHELL window can be holded but the it won't automatically be closed after finished. The statements after the SHELL will only be run when I close the SHELL manually. Do you have any other suggestion?
0
 

Expert Comment

by:idek1
ID: 1432073
I cannot think of why this would not close the shell window, as it actually does exactly this (closes it) when I run it on my machine.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question