long lHandle;
 int nWidth;
int nHeight;
 int nFormat;
 CString flName;
CFile fl;
try{
fl.Open(flName,CFile::modeCreate|CFile::modeWrite);
PUCHAR pBuf;
int nBufLen;
if(!xxxx(nWidth,nHeight,nFormat,&nBufLen))
MessageBox("Alloc memory failed!!!");
pBuf=new UCHAR[nBufLen];
if(fl!=NULL)
{
if(xx(lHandle,nWidth,nHeight,nFormat,pBuf,NULL,&nBufLen))
{
fl.Write(pBuf,nBufLen);
fl.Close();
}
else
{
AfxMessageBox("Failed to capture bitmap");
}
}
主要是文件操作怎样改啊.我在delphi下write方法不对啊,大家帮帮我吧.

解决方案 »

  1.   

    fl.Write(pBuf,nBufLen);用Delphi怎样实现,还在就是我是这样声明的
    pBuf:Pchar;
      

  2.   

    我想应该用f1:TFileStream 代替吧其他的差不多
    Open应该改为Create吧
    xx,xxxx又是什么,没有见过
      

  3.   

    var
      lHandle: THandle;
      nWidth: Integer;
      nHeight: Integer;
      nFormat: Integer;
      flName: String;
      fl: Windows.HFILE;
      pBuf: PCHAR;
      nBufLen: Integer;
      i: Dword;
    begin
    try
        fl := CreateFile(flName,GENERIC_WRITE,0,nil,CREATE_ALWAYS,0,0);   if not (xxxx(nWidth,nHeight,nFormat,@nBufLen)) then
       MessageBox('Alloc memory failed!!!');    GetMem(pBuf,nBufLen);
       //pBuf := new UCHAR[nBufLen];
       if fl <> nil then
        begin
       if xx(lHandle,nWidth,nHeight,nFormat,pBuf,NiL,@nBufLen) then
       begin
            WriteFile(fl,pBuf^,nBufLen,i,nil);
       closehandle(hFile);
       end
       else
       begin
       AfxMessageBox('Failed to capture bitmap');
       end
       end
      

  4.   

    AfxMessageBox('Failed to capture bitmap');改
    MessageBox('Failed to capture bitmap');