close application

close application

Postby Silvio » Sun Aug 24, 2008 4:45 pm

If I open an application extern

LOCAL TS := GetEnv( "windir" ) + "\system32\osk.exe"


sample :

ShellExecute( 0, "open",TS, "", ".", .t. )

How I can close this application ?

I try with hellExecute( 0, "close",TS, "", ".", .t. )

but it not run
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

SHELLEXECUTE

Postby ukoenig » Sun Aug 24, 2008 5:20 pm

Hello Silvio,

The FIVEWIN-sample :

Code: Select all  Expand view

function Main()

   WinExec( "Calc" )        // Let's execute the calculator

   MsgInfo( "Now we will close the calculator" )


   // Use "Calculator" ( or "calc" ? ) in USA for "Calculadora"

   SendMessage( FindWindow( 0, "Calculadora" ), WM_CLOSE )


   MsgInfo( OemToAnsi( "Voil " ) )

return nil




Here is the original description from Microsoft for SHELLEXECUTE :
I think, only OPEN is possible.

Code: Select all  Expand view

HINSTANCE ShellExecute( HWND hwnd,
    LPCTSTR lpOperation,
    LPCTSTR lpFile,
    LPCTSTR lpParameters,
    LPCTSTR lpDirectory,
    INT nShowCmd )



Parameters

hwnd
------
A handle to the owner window used for displaying a user interface (UI) or error messages. This value can be NULL if the operation is not associated with a window.

lpOperation
-------------
-------------
A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs.

The following verbs are commonly used:

edit
Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.

explore
Explores a folder specified by lpFile.

find
Initiates a search beginning in the directory specified by lpDirectory.

open
Opens the item specified by the lpFile parameter. The item can be a file or folder.

print
Prints the file specified by lpFile. If lpFile is not a document file, the function fails.

NULL
In systems prior to Microsoft Windows 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.

In Windows 2000 and later, the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.

// -----------------------

To close the window, a different set of APIs would do the job
As a sample ( not Fivewin ) :

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Const WM_CLOSE = &H10

Private Sub cmdCloseApp_Click()
Dim lngCloseIt As Long
lngCloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
PostMessage lngCloseIt, WM_CLOSE, CLng(0), CLng(0)
End Sub

Regards
uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 23 guests