Solved

VB4: "Winoldap" and "Shell"

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now