The function "EXEC"

Discuss PocketC for CE (including Desktop Edition)

Postby Guillaume on Mon Sep 23, 2002 4:32 pm

With a PocketC softwxare I've opened an external application with the function EXEC("OPEN",FILE,0) but if I want to close this application from my PocketC applet, how can I do ? Is it with the function EXEC or with another ?
Thanks for your time, and for your support
Posts: 6
Joined: Tue Jun 04, 2002 11:57 am
Location: France

Postby guy on Tue Sep 24, 2002 7:41 am

Send a WM_CLOSE message to its main window. This allows the application to terminate gracefully.

This isn't quite as easy as it could be. The PocketC sendmsg() function only allows you to send messages to windows (controls) in the current application. You need to use CEAPI and call the real Windows CE SendMessage() function which will send a message to any window.

The second problem is that you have to know the window handle of the application's main window. Again you can solve this by using a real Windows CE API function. FindWindow() will give you the window handle of a top level window given its title.

Alternatively you can use the brute force method. Again you need to use real CE API calls: open the external application using the CreateProcess() function instead of the PocketC exec() function, then get rid of it later by calling the TerminateProcess() function. This method won't allow the application to clean up gracefully.

The PocketC sendmsg() function calls the API SendMessage() function.
The PocketC exec() function calls the API ShellExecuteEx()function.

PocketC doesn't provide a wrapper for the TerminateProcess() function. If it did then it wouldn't help because the PocketC exec() function doesn't return the handle of the created process (or at least the documentation states that nothing is returned).

PocketC CE API interface:
PCForm and CE API forum:
PocketC CE API interface:
PCForm and CE API forum:
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest