Thread: EXE Closing all instances of Internet explorer - How can it run in Win 95/98

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    1

    EXE Closing all instances of Internet explorer - How can it run in Win 95/98

    Shown below is coding for a simple C++ application that closes Internet Explorer. This application works perfectly in Windows 2000, although when run in a Windows 95/98 environment, two error messages show and the EXE does not run at all.

    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!

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    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....

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    TermianteProcess
    ...your latin roots are really showing through!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to run an exe command in c++ and get back the results?
    By mitilkhatoon in forum C++ Programming
    Replies: 5
    Last Post: 09-21-2006, 06:00 PM
  2. How I can Run exe file in C++
    By palang in forum C++ Programming
    Replies: 2
    Last Post: 05-10-2006, 11:55 AM
  3. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 04:53 PM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 02:58 AM
  5. Error when I run an EXE file
    By dirkduck in forum C++ Programming
    Replies: 12
    Last Post: 03-26-2002, 03:05 PM