BHO에서 Explorer 아닌것은 걸러내기

2010. 10. 14. 17:20언어/C++

extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        // Don't attach to Windows Explorer
        TCHAR pszLoader[MAX_PATH] = {0, };
        GetModuleFileName(NULL, pszLoader, MAX_PATH);
        CString sLoader = pszLoader;
        sLoader.MakeLower() ;
        if (sLoader.Find(_T("explorer.exe")) >= 0)
            return FALSE;

        _Module.Init(ObjectMap, hInstance, &LIBID_CAPTURELib);
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();
    return TRUE;    // ok
}