Segue anexo um exemplo bem simples (CTD 1.5.1) utilizando a implementação da FindWindowA (user32.dll), buscando por titulo de janela.

Sds,
Erasmo

-- 

Erasmo Bispo de Oliveira Junior
Gerente de Pesquisa e Desenvolvimento
Softway - Softcomex Informática Ltda.
Pabx:   +55 (19) 3739.9200
Direto: +55 (19) 3739.9361
Fax:    +55 (19) 3739.9240
e-mail: [EMAIL PROTECTED]
web:    http://www.softcomex.com.br


Marcelo Guimarães wrote:
Caros Colegas,
 
De que forma posso fechar um aplicativo qualquer do windows através de um aplicativo CENTURA ?
 
Atenciosamente,
Marcelo Guimarães



Application Description: Centura SQLWindows/32 Standard Application Template
        Outline Version - 4.0.27
        Design-time Settings
.data VIEWINFO
0000: 6F00000001000000 FFFF01000D004347 5458566965775374 6174650400010000
0020: 0000000000A50000 002C000000020000 0003000000FFFFFF FFFFFFFFFFFCFFFF
0040: FFE9FFFFFFFFFFFF FF000000007C0200 004D010000010000 0001000000010000
0060: 000F4170706C6963 6174696F6E497465 6D00000000
.enddata
.data DT_MAKERUNDLG
0000: 00000000000C4558 45435F5052472E65 78650C455845435F 5052472E646C6C0C
0020: 455845435F505247 2E61706300000101 0126443A5C696E5F 6F75745C41706C69
0040: 63617469766F5C42 4153455C45584543 5F5052472E72756E 26443A5C696E5F6F
0060: 75745C41706C6963 617469766F5C4241 53455C455845435F 5052472E646C6C26
0080: 443A5C696E5F6F75 745C41706C696361 7469766F5C424153 455C455845435F50
00A0: 52472E6170630000 01010126443A5C69 6E5F6F75745C4170 6C6963617469766F
00C0: 5C424153455C4558 45435F5052472E61 706426443A5C696E 5F6F75745C41706C
00E0: 6963617469766F5C 424153455C455845 435F5052472E646C 6C26443A5C696E5F
0100: 6F75745C41706C69 63617469766F5C42 4153455C45584543 5F5052472E617063
0120: 000001010126443A 5C696E5F6F75745C 41706C6963617469 766F5C424153455C
0140: 455845435F505247 2E61706C26443A5C 696E5F6F75745C41 706C696361746976
0160: 6F5C424153455C45 5845435F5052472E 646C6C26443A5C69 6E5F6F75745C4170
0180: 6C6963617469766F 5C424153455C4558 45435F5052472E61 70630000010101
.enddata
                Outline Window State: Normal
                Outline Window Location and Size
.data VIEWINFO
0000: 6600040003002D00 0000000000000000 0000B71E5D0E0500 1D00FFFF4D61696E
0020: 0000000000000000 0000000000000000 0000003B00010000 00000000000000E9
0040: 1E800A00008600FF FF496E7465726E61 6C2046756E637469 6F6E730000000000
0060: 0000000000000000 0000000000003200 0100000000000000 0000E91E800A0000
0080: DF00FFFF56617269 61626C6573000000 0000000000000000 0000000000000000
00A0: 3000010000000000 00000000F51E100D 0000F400FFFF436C 6173736573000000
00C0: 0000000000000000 0000000000000000
.enddata
.data VIEWSIZE
0000: D000
.enddata
                        Left: -0.013"
                        Top:    0.0"
                        Width:  8.013"
                        Height: 4.969"
                Options Box Location
.data VIEWINFO
0000: D4180909B80B1A00
.enddata
.data VIEWSIZE
0000: 0800
.enddata
                        Visible? Yes
                        Left: 4.15"
                        Top:    1.885"
                        Width:  3.8"
                        Height: 2.073"
                Class Editor Location
                        Visible? No
                        Left: 0.575"
                        Top:    0.094"
                        Width:  5.063"
                        Height: 2.719"
                Tool Palette Location
                        Visible? No
                        Left: 6.388"
                        Top:    0.729"
                Fully Qualified External References? Yes
                Reject Multiple Window Instances? No
                Enable Runtime Checks Of External References? Yes
                Use Release 4.0 Scope Rules? No
        Libraries
        Global Declarations
                Window Defaults
                        Tool Bar
                                Display Style? Etched
                                Font Name: MS Sans Serif
                                Font Size: 8
                                Font Enhancement: System Default
                                Text Color: System Default
                                Background Color: System Default
                        Form Window
                                Display Style? Etched
                                Font Name: MS Sans Serif
                                Font Size: 8
                                Font Enhancement: System Default
                                Text Color: System Default
                                Background Color: System Default
                        Dialog Box
                                Display Style? Etched
                                Font Name: MS Sans Serif
                                Font Size: 8
                                Font Enhancement: System Default
                                Text Color: System Default
                                Background Color: System Default
                        Top Level Table Window
                                Font Name: MS Sans Serif
                                Font Size: 8
                                Font Enhancement: System Default
                                Text Color: System Default
                                Background Color: System Default
                        Data Field
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Multiline Field
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Spin Field
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Background Text
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Pushbutton
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                        Radio Button
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Check Box
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Option Button
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                        Group Box
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Child Table Window
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        List Box
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Combo Box
                                Font Name: Use Parent
                                Font Size: Use Parent
                                Font Enhancement: Use Parent
                                Text Color: Use Parent
                                Background Color: Use Parent
                        Line
                                Line Color: Use Parent
                        Frame
                                Border Color: Use Parent
                                Background Color: 3D Face Color
                        Picture
                                Border Color: Use Parent
                                Background Color: Use Parent
                Formats
                        Number: 0'%'
                        Number: #0
                        Number: ###000
                        Number: ###000;'($'###000')'
                        Date/Time: hh:mm:ss AMPM
                        Date/Time: M/d/yy
                        Date/Time: MM-dd-yy
                        Date/Time: dd-MMM-yyyy
                        Date/Time: MMM d, yyyy
                        Date/Time: MMM d, yyyy hh:mm AMPM
                        Date/Time: MMMM d, yyyy hh:mm AMPM
                External Functions
                        Library name: user32.dll
                                Function: FindWindowA
                                        Description:
                                        Export Ordinal: 0
                                        Returns
                                                Number: LONG
                                        Parameters
                                                String: LPSTR
                                                String: LPSTR
                Constants
.data CCDATA
0000: 3000000000000000 0000000000000000 00000000
.enddata
.data CCSIZE
0000: 1400
.enddata
                        System
                        User
                Resources
                Variables
                Internal Functions
                        Function: gf_FindWindow
                                Description:
                                Returns
                                        Window Handle:
                                Parameters
                                        String: p_Ident
                                Static Variables
                                Local variables
                                Actions
                                        Return SalNumberToWindowHandle( 
FindWindowA( STRING_Null, p_Ident ) )
                Named Menus
                Class Definitions
                Default Classes
                        MDI Window: cBaseMDI
                        Form Window:
                        Dialog Box:
                        Table Window:
                        Quest Window:
                        Data Field:
                        Spin Field:
                        Multiline Field:
                        Pushbutton:
                        Radio Button:
                        Option Button:
                        Check Box:
                        Child Table:
                        Quest Child Window: cQuickDatabase
                        List Box:
                        Combo Box:
                        Picture:
                        Vertical Scroll Bar:
                        Horizontal Scroll Bar:
                        Column:
                        Background Text:
                        Group Box:
                        Line:
                        Frame:
                        Custom Control:
                        ActiveX:
                Application Actions
        Form Window: frm_Teste
                Class:
                Property Template:
                Class DLL Name:
                Title: Teste de Fechamento de Programas
                Icon File:
                Accesories Enabled? No
                Visible? Yes
                Display Settings
                        Display Style? Default
                        Visible at Design time? Yes
                        Automatically Created at Runtime? Yes
                        Initial State: Normal
                        Maximizable? Yes
                        Minimizable? Yes
                        System Menu? Yes
                        Resizable? Yes
                        Window Location and Size
                                Left: 5.275"
                                Top:    3.25"
                                Width:  8.033"
                                Width Editable? Yes
                                Height: 2.024"
                                Height Editable? Yes
                        Form Size
                                Width:  Default
                                Height: Default
                                Number of Pages: Dynamic
                        Font Name: Default
                        Font Size: Default
                        Font Enhancement: Default
                        Text Color: Default
                        Background Color: Default
                Description:
                Named Menus
                Menu
                Tool Bar
                        Display Settings
                                Display Style? Default
                                Location? Top
                                Visible? Yes
                                Size: Default
                                Size Editable? Yes
                                Font Name: Default
                                Font Size: Default
                                Font Enhancement: Default
                                Text Color: Default
                                Background Color: Default
                        Contents
                Contents
                        Background Text: Informe o Título da Janela
                                Resource Id: 30577
                                Class Child Ref Key: 0
                                Class ChildKey: 0
                                Class:
                                Window Location and Size
                                        Left: 0.333"
                                        Top:    0.512"
                                        Width:  2.25"
                                        Width Editable? Yes
                                        Height: 0.179"
                                        Height Editable? Yes
                                Visible? Yes
                                Justify: Left
                                Font Name: Default
                                Font Size: Default
                                Font Enhancement: Default
                                Text Color: Default
                                Background Color: Default
                        Data Field: df_Titulo
                                Class Child Ref Key: 0
                                Class ChildKey: 0
                                Class:
                                Property Template:
                                Class DLL Name:
                                Data
                                        Maximum Data Length: Default
                                        Data Type: String
                                        Editable? Yes
                                Display Settings
                                        Window Location and Size
                                                Left: 2.683"
                                                Top:    0.488"
                                                Width:  4.9"
                                                Width Editable? Yes
                                                Height: 0.25"
                                                Height Editable? Yes
                                        Visible? Yes
                                        Border? Yes
                                        Justify: Left
                                        Format: Unformatted
                                        Country: Default
                                        Font Name: Default
                                        Font Size: Default
                                        Font Enhancement: Default
                                        Text Color: Default
                                        Background Color: Default
                                        Input Mask: Unformatted
                                Message Actions
                        Pushbutton: pb_Fechar
                                Class Child Ref Key: 0
                                Class ChildKey: 0
                                Class:
                                Property Template:
                                Class DLL Name:
                                Title: Fechar Aplicativo
                                Window Location and Size
                                        Left: 2.633"
                                        Top:    1.06"
                                        Width:  2.4"
                                        Width Editable? Yes
                                        Height: 0.298"
                                        Height Editable? Yes
                                Visible? Yes
                                Keyboard Accelerator: (none)
                                Font Name: Default
                                Font Size: Default
                                Font Enhancement: Default
                                Picture File Name:
                                Picture Transparent Color: None
                                Image Style: Single
                                Text Color: Default
                                Background Color: Default
                                Message Actions
                                        On SAM_Click
                                                Set hWndTemp = gf_FindWindow( 
df_Titulo )
                                                If hWndTemp = hWndNULL
                                                        Call SalMessageBox( 
'Janela com titulo "' || df_Titulo || '" não encontrada.', 'Erro', 
MB_IconExclamation )
                                                Else
                                                        Call SalPostMsg( 
hWndTemp, SAM_Close, 0, 0 )
                Functions
                Window Parameters
                Window Variables
                        Window Handle: hWndTemp
                Message Actions

Responder a