Best Answer audiopesa , 05 April 2022 - 03:25 PM
Perfecto egostar, ya me compila.
Estaba mirando los metodos en activex de delphi7, que los han cambiado con respecto a delphi 10.2 y me estaba liando.
Gracias
Go to the full postBest Answer audiopesa , 05 April 2022 - 03:25 PM
Perfecto egostar, ya me compila.
Estaba mirando los metodos en activex de delphi7, que los han cambiado con respecto a delphi 10.2 y me estaba liando.
Gracias
Go to the full postPosted 05 April 2022 - 05:58 AM
Hola como están;
Estoy intentancompilar esta unidad en delphi 10.2 y no compila, sin embargo en delphi 7 si funciona
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,ActiveX; type TForm1 = class(TForm) private { Private declarations } public { Public declarations } end; TStreamOwnership = (soReference, soOwned); TStreamAdapter = class(TInterfacedObject, IStream) private FStream: TStream; FOwnership: TStreamOwnership; public constructor Create(Stream: TStream; Ownership: TStreamOwnership = soReference); destructor Destroy; override; function Read(pv: Pointer; cb: Longint; pcbRead: PLongint): HResult; virtual; stdcall; function Write(pv: Pointer; cb: Longint; pcbWritten: PLongint): HResult; virtual; stdcall; function Seek(dlibMove: Largeint; dwOrigin: Longint; out libNewPosition: Largeint): HResult; virtual; stdcall; function SetSize(libNewSize: Largeint): HResult; virtual; stdcall; function CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; out cbWritten: Largeint): HResult; virtual; stdcall; function Commit(grfCommitFlags: Longint): HResult; virtual; stdcall; function Revert: HResult; virtual; stdcall; function LockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; virtual; stdcall; function UnlockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; virtual; stdcall; function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; virtual; stdcall; function Clone(out stm: IStream): HResult; virtual; stdcall; property Stream: TStream read FStream; property StreamOwnership: TStreamOwnership read FOwnership write FOwnership; end; var Form1: TForm1; implementation {$R *.dfm} constructor TStreamAdapter.Create(Stream: TStream; Ownership: TStreamOwnership); begin inherited Create; FStream := Stream; FOwnership := Ownership; end; destructor TStreamAdapter.Destroy; begin if FOwnership = soOwned then begin FStream.Free; FStream := nil; end; inherited Destroy; end; function TStreamAdapter.Read(pv: Pointer; cb: Longint; pcbRead: PLongint): HResult; var NumRead: Longint; begin try if pv = Nil then begin Result := STG_E_INVALIDPOINTER; Exit; end; NumRead := FStream.Read(pv^, cb); if pcbRead <> Nil then pcbRead^ := NumRead; Result := S_OK; except Result := S_FALSE; end; end; function TStreamAdapter.Write(pv: Pointer; cb: Longint; pcbWritten: PLongint): HResult; var NumWritten: Longint; begin try if pv = Nil then begin Result := STG_E_INVALIDPOINTER; Exit; end; NumWritten := FStream.Write(pv^, cb); if pcbWritten <> Nil then pcbWritten^ := NumWritten; Result := S_OK; except Result := STG_E_CANTSAVE; end; end; function TStreamAdapter.Seek(dlibMove: Largeint; dwOrigin: Longint; out libNewPosition: Largeint): HResult; var NewPos: LargeInt; begin try if (dwOrigin < STREAM_SEEK_SET) or (dwOrigin > STREAM_SEEK_END) then begin Result := STG_E_INVALIDFUNCTION; Exit; end; NewPos := FStream.Seek(dlibMove, dwOrigin); if @libNewPosition <> nil then libNewPosition := NewPos; Result := S_OK; except Result := STG_E_INVALIDPOINTER; end; end; function TStreamAdapter.SetSize(libNewSize: Largeint): HResult; begin try FStream.Size := libNewSize; if libNewSize <> FStream.Size then Result := E_FAIL else Result := S_OK; except Result := E_UNEXPECTED; end; end; function TStreamAdapter.CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; out cbWritten: Largeint): HResult; const MaxBufSize = 1024 * 1024; // 1mb var Buffer: Pointer; BufSize, N, I, R: Integer; BytesRead, BytesWritten, W: LargeInt; begin Result := S_OK; BytesRead := 0; BytesWritten := 0; try if cb > MaxBufSize then BufSize := MaxBufSize else BufSize := Integer(cb); GetMem(Buffer, BufSize); try while cb > 0 do begin if cb > MaxInt then I := MaxInt else I := cb; while I > 0 do begin if I > BufSize then N := BufSize else N := I; R := FStream.Read(Buffer^, N); if R = 0 then Exit; // The end of the stream was hit. Inc(BytesRead, R); W := 0; Result := stm.Write(Buffer, R, @W); Inc(BytesWritten, W); if (Result = S_OK) and (Integer(W) <> R) then Result := E_FAIL; if Result <> S_OK then Exit; Dec(I, R); Dec(cb, R); end; end; finally FreeMem(Buffer); if (@cbWritten <> nil) then cbWritten := BytesWritten; if (@cbRead <> nil) then cbRead := BytesRead; end; except Result := E_UNEXPECTED; end; end; function TStreamAdapter.Commit(grfCommitFlags: Longint): HResult; begin Result := S_OK; end; function TStreamAdapter.Revert: HResult; begin Result := STG_E_REVERTED; end; function TStreamAdapter.LockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; begin Result := STG_E_INVALIDFUNCTION; end; function TStreamAdapter.UnlockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; begin Result := STG_E_INVALIDFUNCTION; end; function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; begin Result := S_OK; try if (@statstg <> nil) then with statstg do begin dwType := STGTY_STREAM; cbSize := FStream.Size; mTime.dwLowDateTime := 0; mTime.dwHighDateTime := 0; cTime.dwLowDateTime := 0; cTime.dwHighDateTime := 0; aTime.dwLowDateTime := 0; aTime.dwHighDateTime := 0; grfLocksSupported := LOCK_WRITE; end; except Result := E_UNEXPECTED; end; end; function TStreamAdapter.Clone(out stm: IStream): HResult; begin Result := E_NOTIMPL; end; end.
los errores que me salen son:
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.Seek
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.SetSize
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.CopyTo
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.Commit
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.LockRegion
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.UnlockRegion
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method IStream.Stat
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method ISequentialStream.Read
[dcc32 Error] Unit1.pas(22): E2291 Missing implementation of interface method ISequentialStream.Write
me dice que no estoy implementando los metodos pero si que están
alguna idea?
Posted 05 April 2022 - 11:16 AM
Hola Audiopesa, bienvenido a DelphiAccess
El problema es que la definición de los parámetros son diferentes, necesitas asegurar que tengan los mismos valores,
Por ejemplo el método Seek() tiene las siguientes diferencias
function Seek(dlibMove: Largeint; dwOrigin: Longint; out libNewPosition: Largeint): HResult; virtual; stdcall; function Seek(dlibMove: Largeint; dwOrigin: DWORD; out libNewPosition: LargeUInt): HResult; stdcall;
Saludos
Posted 05 April 2022 - 02:40 PM
Gracias por responder egostar.
esta definición de donde sale..
function Seek(dlibMove: Largeint; dwOrigin: DWORD; out libNewPosition: LargeUInt): HResult; stdcall;
Posted 05 April 2022 - 02:59 PM
Gracias por responder egostar.
esta definición de donde sale..
delphi
function Seek(dlibMove: Largeint; dwOrigin: DWORD; out libNewPosition: LargeUInt): HResult; stdcall;
Hola audiopesa
De la unidad Winapi.ActiveX que es donde se localiza la interfaz IStream.
Saludos
Posted 05 April 2022 - 03:25 PM Best Answer
Perfecto egostar, ya me compila.
Estaba mirando los metodos en activex de delphi7, que los han cambiado con respecto a delphi 10.2 y me estaba liando.
Gracias
Posted 05 April 2022 - 03:33 PM
Perfecto Egostar, ya me compila.
Me estaba liando con los metodos de delphi 7, que son diferentes a delphi 10.2
Gracias, un saludo.
Posted 05 April 2022 - 03:35 PM
Que bien, marcamos como resuelto el hilo.
Saludos