Solved

VB4: "Winoldap" and "Shell"

Posted on 1997-08-24
4
265 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

821 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