![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Oct 2002
Posts: 1
| EXE Closing all instances of Internet explorer - How can it run in Win 95/98 These error messages are: - 'The PSAPI.DLL file is linked to missing export NTDLL.DLL:NtAllocateVirtualMemory.' - '{Directory path where this file is located}\closeexplorer.exe A device attached to the system is not functioning.' How can this coding be altered so that this Application can run in Windows 95/98 as well as Windows 2000? Please can someone help! ================================================== =========== Code:
// - Coding for the close IE/Netscape instances solution - ///////////////////////////////////////
#include "stdafx.h"
#include "psapi.h"
#pragma comment(lib,"psapi.lib")
char *g_sAppName;
boolean g_bVerbose;
boolean KillProcess( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ | PROCESS_TERMINATE,
FALSE, processID );
boolean retval = false;
// Get the process name.
if ( hProcess ) {
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) ) {
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
// Print the process name and identifier.
//Need to
//
_strlwr(szProcessName);
if (!strcmp(szProcessName,"explorer.exe") ||
// Copy and paste the following line with anything else that needs killing
// !strcmp(szProcessName,"netscape.exe") || // change whatever is in the quotes
!strcmp(szProcessName,"iexplore.exe")) {
TerminateProcess(hProcess,0);
}
CloseHandle( hProcess );
}
return retval;
}
int main()
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
int killCount=0;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ))
return 0; // Get the list of process identifiers.
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
if (KillProcess( aProcesses[i] ))
{
killCount++;
}
return killCount;
}
//Just add the Netscape module name and you have it!
|
| joh is offline | |
| | #2 |
| &TH of undefined behavior Join Date: Aug 2001
Posts: 5,183
| PSAPI.DLL is an extention to the API that allows you to manipulate processes.... Unfortunately, it doesnt work on Win98/95/ME...Only NT/2K/XP... You can still call TermianteProcess to actually kill IE, but the methods you have for identifying Internet Explorer processes will not work....
__________________ "If A is success in life, then A equals x plus y plus z. Work is x; y is play; and z is keeping your mouth shut." Albert Einstein (1879 - 1955) Board Rules |
| Fordy is offline | |
| | #3 | |
| Guest Join Date: Aug 2001
Posts: 4,923
| Quote:
| |
| Sebastiani is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to run an exe command in c++ and get back the results? | mitilkhatoon | C++ Programming | 5 | 09-21-2006 06:00 PM |
| How I can Run exe file in C++ | palang | C++ Programming | 2 | 05-10-2006 11:55 AM |
| help with this | tyrantil | C Programming | 18 | 01-30-2005 04:53 PM |
| FlashWindowEx not declared? | Aidman | Windows Programming | 3 | 05-17-2003 02:58 AM |
| Error when I run an EXE file | dirkduck | C++ Programming | 12 | 03-26-2002 03:05 PM |