Windows > Software Development for Windows Client Forums > DirectShow Development > Can't register custom filter."g_hInst != 0 ..."
Ask a questionAsk a question
 

AnswerCan't register custom filter."g_hInst != 0 ..."

  • Monday, March 03, 2008 2:57 PMyuanhangG Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I tried to write my own filter. When i tried to register it, I got this message.
    g_hInst != 0
    At line 387 of D:\Program Files\DXSDK\Samples\C++\DirectShow\BaseClasses\dllsetup.cpp
    Comtinue?

    Anyone can tell me why this happens?

    this is my code maybe related.
    //////////////////////////////////////////////////////////////////////////////

    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
    BOOL WINAPI DllEntryPoint(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
    {
        return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
    }

    STDAPI DllRegisterServer()
    {
        return AMovieDllRegisterServer2( TRUE );
    }

    STDAPI DllUnregisterServer()
    {
        return AMovieDllRegisterServer2( FALSE );
    }

Answers

  • Monday, March 03, 2008 3:49 PMChris P_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Shouldn't that be:

     

    Code Snippet

    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

    BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved)

    {

    return DllEntryPoint(reinterpret_cast<HINSTANCE>(hDllHandle), dwReason, lpReserved);

    }

     

     

     

    Your DllEntryPoint is calling itself?  The official DllEntryPoint() is in the baseclasses and calls _DllEntryPoint() in the same module that initializes the CRT.

     

    Either implement DllMain() as your entry point or change the entry point for the DLL to DllEntryPoint() and remove your implementation.

All Replies

  • Monday, March 03, 2008 3:49 PMChris P_MVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Shouldn't that be:

     

    Code Snippet

    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

    BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved)

    {

    return DllEntryPoint(reinterpret_cast<HINSTANCE>(hDllHandle), dwReason, lpReserved);

    }

     

     

     

    Your DllEntryPoint is calling itself?  The official DllEntryPoint() is in the baseclasses and calls _DllEntryPoint() in the same module that initializes the CRT.

     

    Either implement DllMain() as your entry point or change the entry point for the DLL to DllEntryPoint() and remove your implementation.

  • Wednesday, March 05, 2008 12:07 PMyuanhangG Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you Chris P.!

  • Tuesday, November 03, 2009 10:20 AMmynameisnotcarlos Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Chris,

    unfortunately, that won't work for me either. If I implement DllEntryPoint, an error appears that DllEntryPoint was already declared (baseclasses). If I set "DllEntryPoint" as my entry point for my DLL, I get the error that DllEntryPoint is unresolved.

    What's wrong?

    Thank you

    Edit:
    Whoops! I used the debugging version of the baseclass library. Works fine now (no implementation or setting of the entry point necessary).
    So, the registration works fine but for some reason I can't use the filter -> "The filter could not be created. Resources used by this filter may already be in use." Well, I'm not using that filter at the same time, that's for sure.
    Code: 0x800401F9

    Edit2:
    Here's the solution
    I forgot to mention that I use MFC, so the story with the entry point causes the problems.
    Solved now!