DECLARE INTEGER GetCurrentProcess IN WIN32API DECLARE INTEGER TerminateProcess IN WIN32API INTEGER hProcess, INTEGER uExitCode CLOSE DATABASE ALL CLOSE ALL FLUSH =TerminateProcess(GetCurrentProcess(),99) && 99 can be any number you likeIf you discover that the ActiveX control is running on a separate thread from VFP, you could use the following to try just killing off that thread:
DECLARE INTEGER GetCurrentProcessId IN WIN32API DECLARE INTEGER GetCurrentProcess IN WIN32API DECLARE INTEGER GetCurrentThreadId IN WIN32API DECLARE INTEGER TerminateThread IN WIN32API INTEGER hThread, INTEGER uExitCode DECLARE INTEGER GetWindowThreadProcessId IN WIN32API INTEGER hWnd, INTEGER @ lpdwProcessID DECLARE INTEGER OpenThread IN WIN32API INTEGER dwDesiredAccess, ; INTEGER bInheritHandle, ; INTEGER dwThreadID #DEFINE THREAD_TERMINATE 0x1 * * I assume that you've saved the hWnd of the ActiveX in nActiveXhWnd * LOCAL nProcessID, nThreadID, nThreadHandle nProcessID = 0 nThreadID = GetWindowThreadProcessId(nActiveXhWnd, @nProcessID) IF BITOR(nProcessID,0) = BITOR(GetCurrentProcessId(),0) && ActiveX runs in process IF ! (BITOR(nThreadID,0) = BITOR(GetCurrentThreadId(),0)) && ActiveX runs on its own thread nThreadHandle = OpenThread(THREAD_TERMINATE,1,nThreadID) IF nThreadHandle # 0 =TerminateThread(nThreadHandle,99) ELSE * Unable to open thread with TERMINATE permission ENDIF ELSE * ActiveX runs on the same thread as VFP - kill at your own risk * since you'll kill the VFP session, too. * If you want to get VFP to commit hara-kiri, add code to close files * and release thingies, and after that, uncomment the next line: * =TerminateThread(GetCurrentThread(),99) ENDIF ELSE * ActiveX runs on an out-of-process server; you need to kill the process * running the ActiveX component, and you may need to play with access * tokens in order to get the necessary permissions under NT-family OSes * If you want to get VFP to commit hara-kiri, add code to close files * and release thingies, and after that, uncomment the next line: * =TerminateProcess(GetCurrentProcess(),99) * There's code in my API_APPRUN class to kill another process ENDIF