AviFileOpen неработатет если распаложена в DLL, писал на С++ в Visual C++ Express. GetLastError возращает 0, сама функция возращает чегото неясное (в MSDN такого кода ошибки нет) Код | void ErrorExit(LPTSTR lpszFunction) { // Retrieve the system error message for the last-error code
LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError();
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf), TEXT("%s failed with error %d: %s"), lpszFunction, dw, lpMsgBuf); MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); ExitProcess(dw); }
unsigned int FormatAviMessage(HRESULT code, char *buf,unsigned int len) { const char *msg="unknown avi result code"; switch (code) { case S_OK: msg="Success"; break; case AVIERR_BADFORMAT: msg="AVIERR_BADFORMAT: corrupt file or unrecognized format"; break; case AVIERR_MEMORY: msg="AVIERR_MEMORY: insufficient memory"; break; case AVIERR_FILEREAD: msg="AVIERR_FILEREAD: disk error while reading file"; break; case AVIERR_FILEOPEN: msg="AVIERR_FILEOPEN: disk error while opening file"; break; case REGDB_E_CLASSNOTREG: msg="REGDB_E_CLASSNOTREG: file type not recognised"; break; case AVIERR_READONLY: msg="AVIERR_READONLY: file is read-only"; break; case AVIERR_NOCOMPRESSOR: msg="AVIERR_NOCOMPRESSOR: a suitable compressor could not be found"; break; case AVIERR_UNSUPPORTED: msg="AVIERR_UNSUPPORTED: compression is not supported for this type of data"; break; case AVIERR_INTERNAL: msg="AVIERR_INTERNAL: internal error"; break; case AVIERR_BADFLAGS: msg="AVIERR_BADFLAGS"; break; case AVIERR_BADPARAM: msg="AVIERR_BADPARAM"; break; case AVIERR_BADSIZE: msg="AVIERR_BADSIZE"; break; case AVIERR_BADHANDLE: msg="AVIERR_BADHANDLE"; break; case AVIERR_FILEWRITE: msg="AVIERR_FILEWRITE: disk error while writing file"; break; case AVIERR_COMPRESSOR: msg="AVIERR_COMPRESSOR"; break; case AVIERR_NODATA: msg="AVIERR_READONLY"; break; case AVIERR_BUFFERTOOSMALL: msg="AVIERR_BUFFERTOOSMALL"; break; case AVIERR_CANTCOMPRESS: msg="AVIERR_CANTCOMPRESS"; break; case AVIERR_USERABORT: msg="AVIERR_USERABORT"; break; case AVIERR_ERROR: msg="AVIERR_ERROR"; break; } unsigned int mlen=(unsigned int)strlen(msg); if (buf==0 || len==0) return mlen; unsigned int n=mlen; if (n+1>len) n=len-1; strncpy(buf,msg,n); buf[n]=0; return mlen; }
....
if((hRes = AVIFileOpen(&m_pFile, _TEXT("C:\\video.avi"), OF_WRITE | OF_CREATE, NULL)) == AVIERR_OK) { .... } else{ TCHAR BUF[512];
FormatAviMessage(hRes, BUF, 512);
MessageBox(GetForegroundWindow(), BUF, 0, 0);
ErrorExit("AviFileOpen"); }
|
|