Solved

VB4: "Winoldap" and "Shell"

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

829 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