Solved

How to use CloseWindow ?

Posted on 1998-12-03
4
784 Views
Last Modified: 2010-07-27
Hello !

I use Word 7 with Delphi 3.
To open Word I use this code :
WinExec(PChar('c:\msoffice\winword\winword.exe'),SW_SHOW);
How to know the handle of the Word window to use CloseWindow
to close it ?

Thanx for advance.
0
Comment
Question by:nk51
  • 2
4 Comments
 

Author Comment

by:nk51
ID: 1349109
I found the shellexecute function return the handle but have you an example of using of this function, please ?
Thanx
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1349110
NK51!
I have a TLauncher component (made according to R.Konopka) which is a good interface to ShellExecute and ShellExecuteEx functions. If you'd like, I will send its source to you. Give me your E-mail address and I'll send it to you.
SASSAS
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1349111
nk51

To find the handle for word window and minimize it which is what closewindow does use this code

procedure TForm1.Button1Click(Sender: TObject);
var
Hwd: HWND;
begin
  Hwd := FindWindow('OpusApp', nil);
   CloseWindow(Hwd);
end;

or if wish to close the app down use this code

PostMessage(FindWindow('OpusApp', nil), WM_QUIT, 0, 0);

You can use the FindWindow API to get the handle of an app as first example

Later
BoRiS
0
 

Author Comment

by:nk51
ID: 1349112
For SASSAS :
I'm very interesting by this component.
my email is : nkohut@micropole.com
thanx.

For BORIS :
Your answer is correct BORIS.
You're great !
Thanx.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
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…

895 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