?
Danke für den Link, es klappt aber nicht.
Hier mal der Code
// ipod.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <tlhelp32.h>
#include <windows.h>
# include<shellapi.h>
#include <direct.h> // for getcwd
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
void printError( TCHAR* msg );
BOOL KillProcessByName(char *szProcessToKill);
int _tmain(int argc, _TCHAR* argv[])
{
/*Variablen & String's !
int Zahl = 300 ;
cout << Zahl ;
//*************************
string Vorname;
cout << "Vornamen eingeben: " ;
cin >> Vorname;
cout << "\n\n\n" << "Hallo " << Vorname << "!" ;*/
// Allgemein
int x;
SetConsoleTitleA("Console by Alexander");
cout << "Programm Name\n" ;
cout << "******************************************************************\n\n" ;
cout << "Welcome, don't forget to make a donation if you like this tool.\n" ;
cout << "This tool is free DO NOT SELL IT ON EBAY!!\n" ;
cout << "Write me an E-mail at info[at]the-franky.de\n\n" ;
cout << "******************************************************************\n" ;
cout << "Do you want so start it ?\n\n";
cout << "1: Starting the Programm !\n";
cout << "2: Your Help !\n";
cout << "0: Exit.\n\n";
do
{
cout << "Please Select: ";
cin >> x;
}while((x<0)||(x>2)); // x != 3
switch(x)
{
case 1: system("cls");
// _MAX_PATH is the maximum length allowed for a path
char CurrentPath[_MAX_PATH];
// use the function to get the path
GetCurrentPath(CurrentPath);
// display the path for demo purposes only
char temp[_MAX_PATH];
cout << CurrentPath << endl;
cin.getline(temp,_MAX_PATH);
cout << "\n******************************************************************\n" ;
cout << " Warning the programm is now running !" ;
cout << "\n******************************************************************\n" ;
cout << "\nSuccessfully.\n" ;
cout << "\nPush any Key to EXIT the Programm, be carefull.";
//
ShellExecute(
NULL,
_T("open"),
_T("Externes Programm.exe"), // Ist im gleichen Ordner
_T("22 22"), // Programm mit 22 22 ausführen
NULL,
SW_MINIMIZE);
break ;
case 2: system("cls");
cout << "******************************************************************" << endl;
cout << " Your Help !" << endl;
cout << "******************************************************************" << endl;
cout << "Write an E-mail with 'Help Me' at info[at]the-franky.de" << endl;
cout << "Thank you for your understanding\n" << endl;
cout << "******************************************************************\n\n" ;
cout << "Do you want so start it now?\n\n";
cout << "1: Starting the Programm !\n";
cout << "0: Exit.\n\n";
int y;
do
{
cout << "Please Select: ";
cin >> y;
}while((y<0)||(y>1));
switch(y)
{
case 0:
cout << "DIE NULL";; break;
case 1:
cout << "DIE EINS";; break;
}
break ; // Für die andere Schleife
case 0: exit (1);
}
//system("pause");
KillProcessByName("Externes Programm.exe"); // Anstatt Icq.exe halt "Test.exe" eingeben!
_getch();
return 0;
}
BOOL KillProcessByName(char *szProcessToKill)
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
printError( "CreateToolhelp32Snapshot (of processes)" );
return( FALSE );
}
pe32.dwSize = sizeof( PROCESSENTRY32 );
if( !Process32First( hProcessSnap, &pe32 ) )
{
printError( "Process32First" );
CloseHandle( hProcessSnap );
return( FALSE );
}
do{
if(!strcmp(pe32.szExeFile,szProcessToKill))
{
printf("Prozess: %s \n",pe32.szExeFile);
printf("PID: %d \n",pe32.th32ProcessID );
hProcess = OpenProcess(PROCESS_TERMINATE,0, pe32.th32ProcessID);
TerminateProcess(hProcess,0);
CloseHandle(hProcess);
}
} while( Process32Next(hProcessSnap,&pe32) );
CloseHandle( hProcessSnap );
return( TRUE );
}
void printError( TCHAR* msg )
{
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
eNum = GetLastError( );
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, eNum,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
sysMsg, 256, NULL );
// Trim the end of the line and terminate it with a null
p = sysMsg;
while( ( *p > 31 ) || ( *p == 9 ) )
++p;
do { *p-- = 0; } while( ( p >= sysMsg ) &&
( ( *p == '.' ) || ( *p < 33 ) ) );
// Display the message
printf( "\n WARNING: %s failed with error %d (%s)", msg, eNum, sysMsg );
}