神龙卡的回调函数中的参数如何取得的?(50分)

  • 主题发起人 主题发起人 enzhiyiqiu
  • 开始时间 开始时间
E

enzhiyiqiu

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,该回调函数好象没有地方给他传递参数……
 
哪位大哥知道啊,他的参数是如何传递的??
急~~~~~
 
怎么没人帮忙吗??我都搜索了n多了,都没找到相关的,哪位高手帮帮忙啊!!!··!!!!!!!·
 
写在打开文件的地方就行了
begin

var FMPOpenStruct:TFMP_OPEN_STRUCT;
begin

if openDialog1.Execute then

PPlayName:=openDialog1.FileName;
Fillchar(FMPOpenStruct,sizeof(TFMP_OPEN_STRUCT),0);
FMPOpenStruct.lpFileName:=Pchar(PPlayName);
FMPOpenStruct.dwCallBack:=DWORD(@FMPCallbackProc);
FMPEGStream:=FMPOpen(FMPF_BUFFERS,DWORD(@FMPOpenStruct));

FMPPlay(FMPEGStream,FMPF_POS_END or FMPF_END_STOP,0);
end;


Function FMPCallbackProc(bMsg: Byte;
hMPEGStream: Byte;
dwValue: DWORD): WORD stdcall;
var
Buf:PBuf;
i:integer;
begin

Result:= 0;
try
Buf:= Pointer(FMPGet(hMPEGStream, FMPI_STM_USER));
case bMsg of

FMPM_BUF_CREATE: //创建缓冲区
begin

GetMem(Buf,sizeof(TBuf));
//Buf := GlobalAllocPtr(GMEM_FIXED,sizeof(TBuf));
if Buf=nil then

begin

//分配内存出错,可能是内存不足
Result:=FMPE_DOS;
Exit;
end;


Fillchar(Buf^,sizeof(TBUF),0);
Buf^.hFile:= CreateFile(pChar(PPlayName),//TFMP_OPEN_STRUCT(dwValue).lpFileName,
GENERIC_READ,FILE_SHARE_READ,Nil,OPEN_EXISTING,0,0);
if (Buf^.hFile=INVALID_HANDLE_VALUE) then

begin

//打开文件出错
FreeMemory(buf);
//GlobalFreePtr( Buf );
Result:=FMPE_DOS;
Exit;
end;


for i := 0 to MAX_BUF_NUMBER-1do

GetMem(Buf^.Buffer,MAX_BUF_SIZE + 2);
//GlobalAllocPtr(GMEM_FIXED, );
Buf^.wIndex := 0;
Buf^.dwSize := 0;
//存储缓冲区结构到用户段
FMPSet(hMPEGStream,FMPI_STM_USER, DWORD(Buf) );
//在到缓冲区3/4时,触发填充下一个缓冲区
FMPSet(hMPEGStream, FMPI_BUF_POS, DWORD(Trunc(MAX_BUF_SIZE* 0.75)));
//FMPSet(hMPEGStream,FMPI_BUF_MODE,FMPF_BUF_LOOP);
end;


//关闭缓冲区
FMPM_BUF_CLOSE :
begin

CloseHandle(Buf^.hFile);
for i:=0 to MAX_BUF_NUMBER-1do

FreeMemory(Buf^.Buffer);
//GlobalFreePtr(Buf^.Buffer);
FreeMemory(Buf);
//GlobalFreePtr(Buf);
end;


//跳跃
FMPM_BUF_SEEK:
begin

SetFilePointer(Buf^.hFile,dwValue,nil,FILE_begin
);
end;

//读书据
FMPM_BUF_POS:
begin

ReadFile(Buf^.hFile,Buf^.Buffer[Buf^.wIndex]^,MAX_BUF_SIZE,Buf^.dwSize,nil);
end;

// 缓冲区空
FMPM_BUF_EMPTY :
begin

FMPSet(hMPEGStream, FMPI_BUF_SIZE,Buf^.dwSize );
FMPSet(hMPEGStream, FMPI_BUF_ADDRESS, DWORD(Buf^.Buffer[Buf^.wIndex]));
Inc(Buf^.wIndex);
if (Buf^.wIndex = MAX_BUF_NUMBER) then

Buf^.wIndex:=0;
//Buf^.wIndex := MAX_BUF_NUMBER MOD Buf^.wIndex;
end;


//错误
FMPM_ERROR:
begin

// if Assigned(FOnError) then

// FOnError(Self);
end;

//操作完成
FMPM_COMPLETED :
begin

if dwValue = 3 then
// 播完
begin

// if Assigned(FOnPlayOK) then

// FOnPlayOK(Self);
end;

end
end;

except
//异常
CloseHandle(Buf^.hFile);
for i:=0 to MAX_BUF_NUMBER-1do

FreeMemory(Buf^.Buffer);
FreeMemory(Buf);
end;

end;


 
可是我并没用文件路径来做的啊,是这样的:发一个需要接收的编号给服务器端,服务器端再把该编号的数据传送过来,客户端建立一个虚拟内存,保存服务器段发回的数据,呵呵,不过已经基本解决了,不过谢谢你:)
 
后退
顶部