这些天研究ffmpeg的解码部分,感觉不知从何入手,甚是郁闷故请教于各位大侠,望各位不吝赐教!我现在已经将ffmpeg的工程在minsys+mingw 下编译通过了,但不知道在window下如何使用DLL文件,最好有调用的例子。谢谢

解决方案 »

  1.   

    // A simple program that uses LoadLibrary and 
    // GetProcAddress to access myPuts from Myputs.dll. 
     
    #include <windows.h> 
    #include <stdio.h> 
     
    typedef int (__cdecl *MYPROC)(LPWSTR); 
     
    VOID main(VOID) 

        HINSTANCE hinstLib; 
        MYPROC ProcAdd; 
        BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 
     
        // Get a handle to the DLL module.
     
        hinstLib = LoadLibrary(TEXT("myputs")); 
     
        // If the handle is valid, try to get the function address.
     
        if (hinstLib != NULL) 
        { 
            ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); 
     
            // If the function address is valid, call the function.
     
            if (NULL != ProcAdd) 
            {
                fRunTimeLinkSuccess = TRUE;
                (ProcAdd) (L"Message sent to the DLL function\n"); //<====这里就是调用
            }
     
            // Free the DLL module.
     
            fFreeResult = FreeLibrary(hinstLib); 
        } 
     
        // If unable to call the DLL function, use an alternative.
     
        if (! fRunTimeLinkSuccess) 
            printf("Message printed from executable\n"); 
    }
      

  2.   

    编译好动态库,把dll放到你的工程路径等,然后LoadLibrary加载dll,GetProcAddress获得函数地址,然后赋值给函数指针,调用... FreeLibrary释放DLL
      

  3.   

    FFMPEG 中有几个代码:如 FFMpeg.c,FFPlay.c等
      

  4.   

    HINSTANCE hLib=LoadLibrary("dllname"); 
    if (hLib != NULL) 

            ProcAdd = (MYPROC) GetProcAddress(hLib, "myPuts"); 
     
            if (NULL != ProcAdd) 
            {
                fRunTimeLinkSuccess = TRUE;
                (ProcAdd) (L"Message sent to the DLL function\n"); //<====这里就是调用
            }
         //如果需要调用其他的接口函数,重复上述的 GetProcAddress 及调用过程即可      FreeLibrary(hLib); 
    }  
      

  5.   

    直接看DLL有几个export函数  重复上面工作即可
      

  6.   

    学习就直接用别人的SDK3.2吧,里面有库文件,自己编译的时候加上一句话和VC关联起来也能得到库文件的,至于是啥偶就忘啦,不过网上有很多介绍的,直接调用Dll是个办法,就是感觉太麻烦了
      

  7.   

    编译好动态库,把dll放到你的工程路径等,然后LoadLibrary加载dll,GetProcAddress获得函数地址,然后赋值给函数指针,调用... FreeLibrary释放DLLfor example:HINSTANCE hLib=LoadLibrary("dllname"); 
    if (hLib != NULL) 

            ProcAdd = (MYPROC) GetProcAddress(hLib, "myPuts");         if (NULL != ProcAdd) 
            { 
                fRunTimeLinkSuccess = TRUE; 
                (ProcAdd) (L"Message sent to the DLL function\n"); // <====这里就是调用 
            } 
        //如果需要调用其他的接口函数,重复上述的 GetProcAddress 及调用过程即可       FreeLibrary(hLib); 
    }