Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB4: "Winoldap" and "Shell"

Posted on 1997-08-24
4
Medium Priority
?
284 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

670 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