Menu

Resource leak: explorer

2020-02-09
2020-02-14
  • Safe Online World Ltd.

    #if !defined(_close_handle)
    #   define _close_handle(handle)\
    if (CloseHandle(handle)){\
        handle = INVALID_HANDLE_VALUE;\
    }
    #endif//!_close_handle
    
    int terminate_process(DWORD dwPid) {
        HANDLE explorer;
        explorer = OpenProcess(PROCESS_ALL_ACCESS, false, dwPid);
        int ret = -1;
        if (!(explorer == INVALID_HANDLE_VALUE || explorer == NULL)) {
            DWORD le = GetLastError();
            if (le == ERROR_ACCESS_DENIED)return -501;
            if (le == ERROR_INVALID_PARAMETER)return -500;
            TerminateProcess(explorer, 1);
            ret = 1;
            _close_handle(explorer);
        }
        return ret;
    }
    
     

    Last edit: Safe Online World Ltd. 2020-02-09
  • Safe Online World Ltd.

    Thanks for your suggestion. I've solved this issue. See Here

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.