HI
all.
I have been trying
all weekend to do something in DelphiI can do in VB.
Basically, my VB
app. gets a file, opens it, then loads the bytes into a Variant Array, which
then gets passed to an ASP page which uses Response.Binary write to display the
image.
In Delphi, I can
create a variant arry by using
VarArrayCreate([0,iSize],VarVariant)
This is ok, BUT I am
having a HELL of time trying to work out how to load the bytes in the file
into the Variant array. I can do it, but when I pass it back tot eh ASP Page, I
get "Invalid variant operation
" as an error.
" as an error.
I am doing something
wrong I am sure, but what, I dont know.
Can anyone help
?....Cheers Jeremy Coulter ......P.S.here is my Delphi code
:-
function Timg.Img:
OleVariant;
var
v : Variant;
fFile : File;
iSize : Longint;
data : Pointer;
buf : array of byte;
begin
var
v : Variant;
fFile : File;
iSize : Longint;
data : Pointer;
buf : array of byte;
begin
assignfile(fFile,'g:\device1.gif');
reset(fFile,1);
iSize:=FileSize(fFile);
reset(fFile,1);
iSize:=FileSize(fFile);
v:=VarArrayCreate([0,iSize-1],VarVariant);
data:=VarArrayLock(v);
seek(fFile,0);
BlockRead(fFile,Data^,sizeof(buf));
VarArrayUnlock(v);
CloseFile(fFile);
Result :=v;
end;
data:=VarArrayLock(v);
seek(fFile,0);
BlockRead(fFile,Data^,sizeof(buf));
VarArrayUnlock(v);
CloseFile(fFile);
Result :=v;
end;
////////////
ASP
Code
<%
Dim obj
Set obj = CreateObject("imagetest.img")
response.ContentType="image/GIF"
response.binarywrite obj.img
set obj=nothing
%>