请各位帮我把以下的一段VC++的代码转换成Delphi的,不胜感激 (50分)

  • 主题发起人 主题发起人 poppy
  • 开始时间 开始时间
P

poppy

Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
WORD CALLBACK FMPCallbackProc( BYTE bMsg, BYTE hMPEGStream, DWORD dwValue )
{
	int i;
	struct TBuf *Buf;
	Buf= (struct TBuf *)FMPGet( hMPEGStream, FMPI_STM_USER);
	switch( bMsg )
	{
        // first message received - make all your allocations here
        case FMPM_BUF_CREATE:
			//DWORD dwIndex;
			Buf = (struct TBuf *)GlobalAllocPtr( GMEM_FIXED, sizeof( struct TBuf ) );
			if( !Buf )
            {
				MessageBox(NULL,"Error while allocating TBuf",
							"FMPBuf1::FMPCallbackProc()",
							MB_ICONASTERISK | MB_OK );
                return( FMPE_DOS );
            }
			memset( Buf, '/0', sizeof( struct TBuf ) );
			// Value is the parameter passed when opening the file( ie. filename )
			Buf->hFile = CreateFile(((FMP_OPEN_STRUCT *)dwValue)->lpFileName, GENERIC_READ, FILE_SHARE_READ,
									 NULL, OPEN_EXISTING, 0, 0 );
			// if we cannot open the file, return an error
			// NOTE: the FMPM_BUF_CLOSE is not called when an error occurs
			// during the creation
			if( Buf->hFile == INVALID_HANDLE_VALUE )
			{
				MessageBox( NULL,
							"Error While Opening File",
							"FMPBuf1::FMPCallbackProc()",
							MB_ICONASTERISK | MB_OK );
				GlobalFreePtr( Buf );
				return( FMPE_DOS );
			}
			
            for( i = 0;
i < MAX_BUF_NUMBER;
i++ )
            {
				Buf->Buffer[i] = (char *)GlobalAllocPtr( GMEM_FIXED, MAX_BUF_SIZE + 2 );
            }
            Buf->wIndex = 0;
			Buf->dwSize = 0;
            // store the structure address in the USER field
			FMPSet(hMPEGStream,FMPI_STM_USER, (DWORD)Buf );
            // trigger at 3/4 of the buffer to fill the next buffer
            FMPSet(hMPEGStream, FMPI_BUF_POS, (DWORD)((float)MAX_BUF_SIZE * (float).75));
            break;
        
		// message received when closing the stream - delete buffers
		case FMPM_BUF_CLOSE:
            // close the file
			CloseHandle( Buf->hFile );
            // free all application buffers
            for( i = 0;
i < MAX_BUF_NUMBER;
i++ )
            {
            	GlobalFreePtr( Buf->Buffer[i] );
            }
            GlobalFreePtr( Buf );
			break;
		// message received when a seek is required - seek to the position
		// in Value (specified in bytes)
		case FMPM_BUF_SEEK:
			SetFilePointer( Buf->hFile, (LONG)dwValue, 0, FILE_begin
 );
			break;
        // message received when a buffer has reached its signal position -
        // prepare here the next buffer
        case FMPM_BUF_POS:
			ReadFile( Buf->hFile, Buf->Buffer[Buf->wIndex], MAX_BUF_SIZE,
						  &amp;Buf->dwSize, NULL );
			break;
        // message received when a buffer has been completely read - switch to
        // the next prepared buffer
        case FMPM_BUF_EMPTY:
			FMPSet(hMPEGStream, FMPI_BUF_SIZE, Buf->dwSize );
			FMPSet(hMPEGStream, FMPI_BUF_ADDRESS, (DWORD)(Buf->Buffer[Buf->wIndex]));
			//FMPSet( ghMPEGStream, FMPI_BUF_HANDLE, (DWORD)Buf->BufferIndex[Buf->wIndex] );
            Buf->wIndex++;
			Buf->wIndex %= MAX_BUF_NUMBER;
            break;
        case FMPM_ERROR:
            break;
    }
    return( 0 );
}
 
怎么没人理我啊,分不够可以再加,不过我很穷,没多少分可加了[:D]
 
这里没有VC高手。
 
网上有转换程序,还有相关的文章。可以找找。我以前看过。可以try一下你
 
接受答案了.
 
后退
顶部