本文整理汇总了C++中KillProcess函数的典型用法代码示例。如果您正苦于以下问题:C++ KillProcess函数的具体用法?C++ KillProcess怎么用?C++ KillProcess使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KillProcess函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main_p2
int main_p2(int argc, char *argv[]) {
//assume first argument is the application name
if (argc < 5) {
printf("Error: Invalid number of command line arguments\n");
printf("Program expected the following cli arguments\n");
printf("./p2 init.file log.file, trans1.file, trans2.file\n");
exit(0);
}
int i = 0;
//Gets CLI Values. Tanks if values not provided.
for (i = 1; i < argc; i++) {
//printf("CLI Value:%s\n", argv[i]);
SetCLIValues(argv[i], i);
}
//open all 4 pipes
pipe(pipe1);
pipe(pipe2);
pipe(pipe3);
pipe(pipe4);
//fork store manager
pid_t sm_pid = ForkStoreManager();
//printf("Forked Store Manager\n");
//wait a sec for the store manager to load the input file.
//this is less to do with the store manager doing what it's
//supposed to do and more to prevent the forked processes
//from executing
//sleep(1);
pid1 = ForkProcess(1, trans1FileName, pipe1, pipe3);
//printf("Forked Process 1\n");
pid2 = ForkProcess(2, trans2FileName, pipe2, pipe4);
//printf("Forked Process 2\n");
GetInputFromUser();
//deallocates shared memory
KillProcess(sm_pid);
KillProcess(pid1);
KillProcess(pid2);
return 0;
}
示例2: Defect_INC120743L
/**
@SYMTestCaseID SYSLIB-BAFL-UT-4052
@SYMTestCaseDesc Tests BackupServer crashes under IPC fuzzing and freezes phone
@SYMTestPriority High
@SYMTestActions Calls BackupServer with EBakOpCodeCloseServer with 0-4 args. Verifies that server returns KErrNotSupported.
@SYMTestExpectedResults Server should not process the CloseServer message and should return KErrNotSupported
*/
LOCAL_C void Defect_INC120743L()
{
TheTest.Next (_L ("Defect_INC120743L"));
__UHEAP_MARK;
RProcess server;
TInt messageToTest = EBakOpCodeCloseServer;
//Clean up any chance of launcher or baksrvs still running
TInt err = KillProcess(KServerLauncherProcess);
if((err != KErrNotFound)&&(err != KErrDied))
{
User::LeaveIfError(err);
}
err = KillProcess(KBURServerName);
if((err != KErrNotFound)&&(err != KErrDied))
{
User::LeaveIfError(err);
}
TInt startedFlag = LaunchServer(server);
TheTest.Printf(_L("LaunchServer has returned: %d"), startedFlag);
TheTest(startedFlag == 0 || startedFlag == KErrAlreadyExists);
CTrapCleanup* cleanup=CTrapCleanup::New();
err=KErrNoMemory;
if (cleanup)
{
//Carry out each test with number of arguments 1 - 4
for(TInt argCount = 0; argCount <= 4; argCount++)
{
RIpcServerCloseTest closeTest;
TRAP(err,closeTest.RunTestL(KServerName, messageToTest, argCount));
closeTest.Close();
}
delete cleanup;
}
__UHEAP_MARKEND;
}
示例3: fail
void
TestHangsParent::CleanUp()
{
if (!KillProcess(OtherProcess(), 0, false))
fail("terminating child process");
Close();
}
示例4: Uninstall_Init
codeUNINSTALL_INIT Uninstall_Init(
HWND hwndParent,
LPCTSTR pszInstallDir)
{
// TODO: Add custom uninstallation code here
// To continue uninstallation, return codeUNINSTALL_INIT_CONTINUE
// If you want to cancel installation,
// return codeUNINSTALL_INIT_CANCEL
TCHAR szShortcutPath[MAX_PATH];
TCHAR szOutFileLink[MAX_PATH];
HKEY hKey;
HRESULT hr = S_OK;
KillProcess(_T("VKontakteWM.Notification.exe"));
SHGetSpecialFolderPath(0, szShortcutPath, CSIDL_PROGRAMS, false);
wsprintf(szOutFileLink,_T("%s\\%s"), szShortcutPath, _T("ВКонтакте.lnk"));
DeleteFile(szOutFileLink);
hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Security\\Shell\\StartInfo\\Start"), 0, 0, &hKey);
if(hr == ERROR_SUCCESS)
{
RegDeleteKey(hKey, TEXT("ВКонтакте.lnk"));
RegCloseKey(hKey);
}
return codeUNINSTALL_INIT_CONTINUE;
}
示例5: AddMenuString
void CDlg_AppInfo::OnWnds()
{
CMenu menu;
menu.CreatePopupMenu();
if(hSlWnd!=0){
AddMenuString(&menu,2,_l("Put link on desktop"));
AddMenuString(&menu,3,_l("Autohide window")+"...");
}
AddMenuString(&menu,1,_l("Kill application"));
::SetMenuDefaultItem(menu.m_hMenu, 0, FALSE);
CRect rt;
GetDlgItem(ID_WNDS)->GetWindowRect(&rt);
RECT rDesktopRECT;
rDesktopRECT.left=rDesktopRECT.top=-20;
rDesktopRECT.right=rDesktopRECT.bottom=-10;
HWND wndShotPhase2 = ::CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_TRANSPARENT, "Static", "MENU_WND", WS_DISABLED, rDesktopRECT.left, rDesktopRECT.top, rDesktopRECT.right-rDesktopRECT.left, rDesktopRECT.bottom-rDesktopRECT.top, 0, 0, AfxGetApp()->m_hInstance, 0);
DWORD dwRes=::TrackPopupMenu(menu.m_hMenu, TPM_RETURNCMD, rt.right, rt.top, 0, wndShotPhase2 , NULL);
::DestroyWindow(wndShotPhase2);
if(dwRes==3){
AddToAutoHide(hSlWnd);
}
if(dwRes==1){
KillProcess(dwProcId,NULL);
}
if(dwRes==2){
CreateLinkInFolder(getDesktopPath(),hSlWnd);
}
}
示例6: use
/**
@SYMTestCaseID PDS-SQLITE3SEC-UT-4034
@SYMTestCaseDesc SQL server multi-insert performance test.
The test inserts 1000 records in a single transaction and stores
the execution time for later use (comparison and printing).
@SYMTestPriority High
@SYMTestActions SQL server multi-insert performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ REQ11320
*/
static void SqlServerMultiInsertTest(const char aInsertSql[], TInt aInsertRecCnt)
{
TheTest.Next( _L("@SYMTestCaseID:PDS-SQLITE3SEC-UT-4034"));
(void)KillProcess(KSqlSrvName);
TInt err = TheDb.Open(KTestDbName);
TEST2(err, KErrNone);
RSqlStatement stmt;
err = stmt.Prepare(TheDb, TPtrC8((const TUint8*)aInsertSql));
TEST2(err, KErrNone);
TUint32 fc = FastCounterValue();
err = TheDb.Exec(_L8("BEGIN"));
TEST(err >= 0);
for(TInt i=0;i<aInsertRecCnt;++i)
{
err = stmt.BindInt(0, i + 1);
TEST2(err, KErrNone);
err = stmt.Exec();
TEST2(err, 1);
err = stmt.Reset();
TEST2(err, KErrNone);
}
err = TheDb.Exec(_L8("COMMIT"));
TEST(err >= 0);
StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiInsert, FastCounterValue() - fc);
stmt.Close();
TheDb.Close();
}
示例7: AtTime
void CTimeWorkManager::RunL()
{
if (iState == EUninitialized)
{
// Do something the first time RunL() is called
iState = EInitialized;
AtTime();
}
else if (iState != EError)
{
switch (iStatus.Int())
{
case KErrNone:
{
// Do something
KillProcess();
}
break;
case KErrAbort:
AtTime();
break;
default:
break;
}
}
}
示例8: GetExitCodeProcess
// This is called when the service process exits.
void CServiceRunner::ProcessStopped()
{
// If we are exiting then ignore this notification.
if (m_exiting)
return;
// Get the exit code.
unsigned long exitcode = 0;
GetExitCodeProcess(m_processHandle, &exitcode);
// Clean up.
KillProcess();
// Is a restart required?
if (m_autoRestart || m_forceRestart)
{
if (!m_forceRestart)
m_restartAttempts++;
CEventLogger::Get().Log(EVENTLOG_INFORMATION_TYPE, WEBINOS_SERVER_EVENT_EXIT_RESTART, m_parameters.serviceName.c_str(), 0);
Start();
}
else
{
// The process has exited and we don't want a restart, so exit the service here.
CEventLogger::Get().Log(EVENTLOG_INFORMATION_TYPE, WEBINOS_SERVER_EVENT_EXIT_REALLY, m_parameters.serviceName.c_str(), 0);
Exit(exitcode);
}
}
示例9: KillProcessTreeWinHelper
//---------------------------------------------------------------------------
// KillProcessTreeWinHelper
//
// This is a recursive helper function that terminates all the processes
// started by the specified process and them terminates the process itself
//
// Parameters:
// dwProcessId - identifier of the process to terminate
//
// Returns:
// Win32 error code.
//
BOOL WINAPI KillProcessTreeWinHelper(DWORD dwProcessId) {
// create a snapshot
auto_handle hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (!hSnapshot)
return GetLastError();
auto_localmem<PROCESSENTRY32*> pEntry = ::LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT,sizeof(PROCESSENTRY32));
pEntry->dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnapshot, pEntry))
{
return GetLastError();
}
// kill all children first
do
{
// there was a report of infinite recursion, so watching out for the obvious self-loop possibility
DWORD pid = pEntry->th32ProcessID;
if (pEntry->th32ParentProcessID == dwProcessId && dwProcessId!=pid)
KillProcessTreeWinHelper(pid);
}
while (Process32Next(hSnapshot, pEntry));
// kill the process itself
if (!KillProcess(dwProcessId))
return GetLastError();
return ERROR_SUCCESS;
}
示例10: KillProcess
void CServiceRunner::ForceRestart()
{
m_forceRestart = true;
// Kill Process and wait for ProcessStopped to be called.
KillProcess();
}
示例11: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
if( argc >= 2 )
::OutputDebugString(argv[1]);
//程序自动重启
if (argc == 2 && lstrcmpi(argv[1], TEXT("-A")) == 0)
{
try
{
i8desk::CWin32Svr::StopService(_T("I8VDiskSvr"));
KillProcess(_T("i8NodeServer.exe"));
}
catch(...)
{
// do nothing
}
Sleep(500);
// 重启服务
i8desk::CWin32Svr::StartService(_T("I8VDiskSvr"));
//StartProcess(_T("I8VDiskSvr.exe -d"));
return 0;
}
g_service.ProcessCmdLine(argc, argv);
return 0;
}
示例12: ProcessArgs
static void ProcessArgs(int argc, char **argv)
{
// If we can't connect to a gimbal, kill the app right now
if (OrionCommOpen(&argc, &argv) == FALSE)
KillProcess("", 1);
}// ProcessArgs
示例13: KillProcessTreeNtHelper
//---------------------------------------------------------------------------
// KillProcessTreeNtHelper
//
// This is a recursive helper function that terminates all the processes
// started by the specified process and them terminates the process itself
//
// Parameters:
// pInfo - processes information
// dwProcessId - identifier of the process to terminate
//
// Returns:
// Win32 error code.
//
static
BOOL
WINAPI
KillProcessTreeNtHelper
(
IN PSYSTEM_PROCESSES pInfo,
IN DWORD dwProcessId
)
{
// _ASSERTE(pInfo != NULL);
PSYSTEM_PROCESSES p = pInfo;
// kill all children first
for (;;)
{
if (p->InheritedFromProcessId == dwProcessId)
KillProcessTreeNtHelper(pInfo, p->ProcessId);
if (p->NextEntryDelta == 0)
break;
// find the address of the next process structure
p = (PSYSTEM_PROCESSES)(((LPBYTE)p) + p->NextEntryDelta);
}
// kill the process itself
if (!KillProcess(dwProcessId))
return GetLastError();
return ERROR_SUCCESS;
}
示例14: _FindAndKillProcess
/* Function: _FindAndKillProcess()
*
* in: LPSTR aProcessName: Name of process to find and kill
* BOOL aKillProcess: Indicates whether to kill the process
* or not.
* purpose: To find and kill a given process name currently running. This
* function only works under Win9x, Win2k, and WinXP systems.
*/
BOOL _FindAndKillProcess(kpf *kpfRoutines, LPSTR aProcessName, BOOL aKillProcess)
{
BOOL rv = FALSE;
HANDLE hCreateSnapshot = NULL;
PROCESSENTRY32 peProcessEntry;
hCreateSnapshot = kpfRoutines->pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hCreateSnapshot == (HANDLE)-1)
return(rv);
peProcessEntry.dwSize = sizeof(PROCESSENTRY32);
if(kpfRoutines->pProcessWalkFirst(hCreateSnapshot, &peProcessEntry))
{
char szBuf[MAX_BUF];
do
{
ParsePath(peProcessEntry.szExeFile, szBuf, sizeof(szBuf), FALSE, PP_FILENAME_ONLY);
/* do process name string comparison here */
if(lstrcmpi(szBuf, aProcessName) == 0)
{
rv = TRUE;
if(aKillProcess)
KillProcess(aProcessName, NULL, peProcessEntry.th32ProcessID);
else
break;
}
} while(kpfRoutines->pProcessWalkNext(hCreateSnapshot, &peProcessEntry));
}
CloseHandle(hCreateSnapshot);
return(rv);
}
示例15: Uninstall_Init
codeUNINSTALL_INIT Uninstall_Init(
HWND hwndParent,
LPCTSTR pszInstallDir
)
{
// Kill process here
KillProcess(TEXT("MobileRemote.exe"));
return codeUNINSTALL_INIT_CONTINUE;
}