You'll first have to know the ClassName of the app you are trying to close. Then use FindWindow to get e handle of the main window. Then you can use SendMessage to send a WM_CLOSE message.
For example with Word 97 (the classname is OpusApp):
var h:Integer;
begin
h:=FindWindow('OpusApp',ni
if h>0 then SendMessage(h,WM_DESTROY,0
end;
Some know class-names are:
Calculator "SciCalc"
Notepad "Notepad"
Paintbrush (Win3x "pbParent"
Paint (Win95) "MSPaintApp"
Write (Win3x) "MSWRITE_MENU"
WordPad (Win95) "WordPadClass"
Word 2/6/7 "OpusApp"
Excel 4/5/7 "XLMAIN"
PowerPoint 4 "PPApplicationClass"
PowerPoint 7 "PP7FrameClass"
ToolBook (authoring "ToolBook"
ToolBook (runtime) "TBKMain"
Windows Help "MS_WINDOC"
WinHelp32 Topic "MS_WINDOC_SECONDARY"
File Manager "WFS_Frame"
Control Panel "CtlPanelClass"
Print Manager "PrintManager"
Explore (Win95) "ExploreWClass"
Program Manager "Progman"
Microsoft Exchange 4.0 "Microsoft Exchange 4.0 Viewer"
Microsoft Internet Explorer 3.0 "IEFrame"
Lotus Organizer 2.1 "TzBook"
Lotus123 5.0 "123WParent"
Lotus Approach 96 "ApproachWClass"
Lotus Freelance Graphics 96 "FLWApp"
Lotus ScreenCam 2.1 "ScreenCamMainWnd"
Lotus WordPro 96 "WordProAppWndNT"
Greetings MvZ
Main Topics
Browse All Topics





by: ronitPosted on 1998-02-15 at 03:20:34ID: 1359259
To Close a notepad document: tepad', nil), wm_Destroy, 0, 0);
SendMessage(FindWindow('no