Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Close another Application
Message
 
To
18/05/2004 23:59:57
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00905160
Message ID:
00905200
Views:
10
You might consider using Windows Scripting to detect the running process and terminating it.
The following will terminate any running Windows Calculator instances (This requires that Windows Scriting be installed on the computer)
terminateProcess('CALC.EXE')
FUNCTION terminateProcess(lcProcess)
lcComputer = "."
loWMIService = Getobject("winmgmts:" ;
    + "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ;
    ("Select * from Win32_Process")
For Each loProcess In colProcessList
   IF UPPER(loProcess.name) = lcProcess
     loProcess.terminate()
   endif
Next
>I try to close another Application eg. Ms Calculator by using API call. I try the following code but it does not work.
>
>
>
>DECLARE INTEGER FindWindow ;
> IN WIN32API STRING cNull,STRING cWinName
>
>
>DECLARE INTEGER SendMessage IN user32;
> INTEGER hWnd,;
> INTEGER Msg,;
> INTEGER wParam,;
> INTEGER lParam
>
>
>mWinHandle = FindWindow(0,'Calculator')
>IF mWinHandle > 0
> SendMessage(mWinHandle,10,0,0)
>ELSE
> MESSAGEBOX(mWinHandle)
>ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform