Тема: ReadFile
Показать сообщение отдельно
Старый 08.10.2007, 18:27   #1  
Eldar9x is offline
Eldar9x
MCTS
Аватар для Eldar9x
Oracle
MCBMSS
 
1,064 / 166 (8) ++++++
Регистрация: 29.09.2006
Адрес: Казань
ReadFile
Привет всем. Помогите написать обертку к ReadFile:
X++:
client server static int ReadFile(  int _hFile, int _nNumberOfBytesToRead )
{
    Binary      data            = new Binary(_nNumberOfBytesToRead);
    Binary      data2           = new Binary(0x4);
    DLL         _winApiDLL      = new DLL('KERNEL32');
    DLLFunction _readFile       = new DLLFunction(_winApiDLL, 'ReadFile');
    boolean     _ret;
    int         iErr;
    str         strErr;


    _readFile.returns(ExtTypes::DWord);

    _readFile.arg( ExtTypes::DWord,
                   ExtTypes::Pointer,
                   ExtTypes::DWord,
                   ExtTypes::Pointer,
                   ExtTypes::DWord);

    _ret =_readFile.call(_hFile, data, _nNumberOfBytesToRead, data2, 0);

    if (!_ret)
    {
            iErr   = winApi::getLastError();
            strErr = winApi::formatMessage(iErr);
            error(strErr);
    }

    return data.dWord(0);
}
пишет "Отказано в доступе ", хандл файла получаю через createfile