首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

函数指针类型转换异常

2012-09-14 
函数指针类型转换错误?C/C++ code// ------------------------------//DYN.h// -------------------------

函数指针类型转换错误?

C/C++ code
// ------------------------------//  DYN.h// ------------------------------#include <Vfw.h>typedefHWND VFWAPI DYN_capCreateCaptureWindowA (                                     LPCSTR lpszWindowName,                                     DWORD dwStyle,                                     int x, int y, int nWidth, int nHeight,                                     HWND hwndParent, int nID);typedefBOOL VFWAPI DYN_capGetDriverDescriptionA (UINT wDriverIndex,                                      LPSTR lpszName, int cbName,                                      LPSTR lpszVer, int cbVer);typedefHWND VFWAPI DYN_capCreateCaptureWindowW (                                     LPCWSTR lpszWindowName,                                     DWORD dwStyle,                                     int x, int y, int nWidth, int nHeight,                                     HWND hwndParent, int nID);typedefBOOL VFWAPI DYN_capGetDriverDescriptionW (UINT wDriverIndex,                                      LPWSTR lpszName, int cbName,                                      LPWSTR lpszVer, int cbVer);#ifdef UNICODE#define pfncapCreateCaptureWindow  pfncapCreateCaptureWindowW;#define pfncapGetDriverDescription pfncapGetDriverDescriptionW;#else#define pfncapCreateCaptureWindow  pfncapCreateCaptureWindowA;#define pfncapGetDriverDescription pfncapGetDriverDescriptionA;#endifextern DYN_capCreateCaptureWindowA *pfncapCreateCaptureWindowA;extern DYN_capCreateCaptureWindowW *pfncapCreateCaptureWindowW;extern DYN_capGetDriverDescriptionA *pfncapGetDriverDescriptionA;extern DYN_capGetDriverDescriptionW *pfncapGetDriverDescriptionW;


C/C++ code
/*************************webcam.h***************************/#include "DYN.h"/**************************************code*******************************************//**************************************code*******************************************//**************************************code*******************************************/bool CVideoCap::IsWebCam(){    if (m_bIsConnected)        return false;    bool    bRet = false;        char    lpszName[100], lpszVer[50];    for (int i = 0; i < 10 && !bRet; i++)    {        bRet = pfncapGetDriverDescription(i, lpszName, sizeof(lpszName), /*此外正常*/            lpszVer, sizeof(lpszVer));    }    return bRet;}/**************************************code*******************************************//**************************************code*******************************************//**************************************code*******************************************/CVideoCap::CVideoCap(){    // If FALSE, the system automatically resets the state to nonsignaled after a single waiting thread has been released.    m_hCaptureEvent = CreateEvent(NULL, FALSE, FALSE, NULL);    m_lpbmi = NULL;    m_lpDIB = NULL;    if (!IsWebCam() || m_bIsConnected)        return;    m_hWnd = CreateWindow("#32770", /* Dialog */ "", WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);    m_hWndCap = pfncapCreateCaptureWindow(  /*出错代码行*/        "CVideoCap",         WS_CHILD | WS_VISIBLE,        0,        0,        0,        0,        m_hWnd,        0        );}


[解决办法]
m_hWndCap = (*pfncapCreateCaptureWindow)( /*出错代码行*/
"CVideoCap", 
WS_CHILD | WS_VISIBLE,
0,
0,
0,
0,
m_hWnd,
0
);

这样试试

热点排行