Solved

Terminate Foreign Windows / Applications

Posted on 2000-04-04
9
163 Views
Last Modified: 2010-05-19
I have an application that is set to run as the Shell. I want to terminate certain windows that are displayed i.e. system messages or other apps that pop up. Does someone have some Delphi 4 code for Windows NT 4?
0
Comment
Question by:skymag
9 Comments
 
LVL 4

Expert Comment

by:jeurk
ID: 2683070
hello, i suggest you take a look here:
http://www.jgsoftware.com/nt.htm
0
 

Author Comment

by:skymag
ID: 2683107
Sorry, but I can't find any relevant information there.
0
 

Author Comment

by:skymag
ID: 2683159
Adjusted points from 100 to 150
0
 

Author Comment

by:skymag
ID: 2683160
I would really appreciate some sample code.
0
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!

 
LVL 20

Expert Comment

by:Madshi
ID: 2683278
What do you know about the program you want to stop? Do you know it's process ID or it's main window handle or [...]?

There are several different possibilites to stop a process. It depends on how you want it to be stopped (e.g. may the user save modified files?) and what you know of that process.

TerminateProcess and PostMessage(windowHandle, WM_CLOSE, 0, 0) are two most common solutions.

Regards, Madshi.
0
 

Author Comment

by:skymag
ID: 2683375
Hi Madshi, I'm using the following code but it doesn't want to close the Internet Explorer. It seems to work on most other applications. I am using the EmbeddedWb Component.

procedure TfMain.WMActivate(var Msg: TWMActivate);
var
  S: String;
  wnd: HWND;
  i: Integer;
begin
  if Msg.Active=0 then
     begin
       wnd := Msg.ActiveWindow;
       if wnd = 0 then
          wnd := GetForegroundWindow;
       i := GetWindowTextLength(wnd);
       SetLength(S, i + 1);
       GetWindowText(Wnd, PChar(S), i + 1);

       if Pos('Internet Explorer', S) > 0 then
          Sendmessage(wnd, WM_CLOSE, 0, 0);
     end;
end;
0
 
LVL 20

Accepted Solution

by:
Madshi earned 150 total points
ID: 2683595
Try "PostMessage(wnd, WM_CLOSE, 0, 0);". But I guess that makes no difference. Please tell me what window text do you get when the explorer is activated? Add a line "caption := S;" to your sources to check that.
0
 

Author Comment

by:skymag
ID: 2683687
That actually closed it down. According to the Win32 Programmer's Guide this is the difference:
The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2683744
listenning
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

14 Experts available now in Live!

Get 1:1 Help Now