15.05.2013, 01:59
|
|
.
|
|
Регистрация: 18.05.2011
Адрес: Омск
Сообщения: 3,970
Версия Delphi: 3,5,7,10,12,XE2
Репутация: выкл
|
|
Код:
function proc_read(buffer : Pointer; length : DWORD; user : Pointer) : DWORD; stdcall;
begin
with MyClass(user).field do
begin
if (field1 >= 0) and (length >= 0) then
begin
Result := field2 - field1;
if Result > 0 then
begin
if Result > length then Result := length;
Move(Pointer(Longint(field3) + field1)^, buffer^, Result);
inc(field1, Result);
Exit;
end;
end;
end;
Result := 0;
end;
Код:
unsigned long WINAPI proc_read(void *buffer, unsigned long length, void *user)
{
CMyClass *pMyClass = (CMyClass *)user;
if (pMyClass->field.field1 >= 0 && length >= 0)
{
unsigned long i = (pMyClass->field.field2 - pMyClass->field.field1);
if (i > 0)
{
if (i > length)
i = length;
memmove(buffer, (pMyClass->field.field3 + pMyClass->field.field1), i);
pMyClass->field.field1 += i;
return i;
}
}
return 0;
}
Bargest, посмотри что не так с memmove.
__________________
Je venus de nulle part
55.026263 с.ш., 73.397636 в.д.
|