I read a previous message posted in February on this newsgroup concerning
this topic.
My question is basically the same, how can I duplicate the functionality of
the convert utility, programmatically?
I have tried the following code:
Var
InputStream : TMemoryStream ;
OutputStream : TMemoryStream ;
slstDfm : TStringList ;
...
slstDfm := TStringList.Create ;
InputStream := TMemoryStream.Create ;
InputStream.LoadFromFile(_InputStreamName) ;
OutputStream := TMemoryStream.Create ;
ObjectBinaryToText(InputStream, OutputStream) ;
slstDfm.LoadFromStream(OutputStream) ;
ShowMessage(IntToStr(slstDfm.Count)) ;
slstDfm.SaveToFile(_OutputFileName) ;
However this isn't working. I am tracing into the call to
ObjectBinaryToText, and there is a problem with the signature.
Please don't tell me that I have to call the RegisterClasses function. The
borland developed convert utility avoids calling this function, because it
cannot know in advance all of the different types of components it will
encounter on a form. If I cannot duplicate the functionality using the
ObjectBinaryToText function, I will programmatically execute the convert
utility, but I really would like to avoid doing this.
Thank you for any assistance,
Richard Rogers.
in article <3adefe58$2_2@dnews>, you wrote:
> However this isn't working. I am tracing into the call to
> ObjectBinaryToText, and there is a problem with the signature.
>
you want ObjectResourceToText not ObjectBinary...
here's an examples that fills a TStrings descendent with the text version of a
DFM:
function DfmToList(const ADfmFile: string; AList: TStrings): boolean;
{ Convert filename.dfm to text and populate a TStrings with it. Assumes
that DfmFile exists and that AList has been created.
}
var
dfmStream: TMemoryStream;
txtStream: TMemoryStream;
begin
Result := True;
dfmStream := nil;
txtStream := nil;
dfmStream := TMemoryStream.Create; { Create stream for binary }
txtStream := TMemoryStream.Create; { Create stream for text }
try
try
dfmStream.LoadFromFile(ADfmFile);
ObjectResourceToText(dfmStream, txtStream); { Do conversion }
txtStream.Position := 0; { Text stream to beginning }
AList.LoadFromStream(txtStream); { Populate AList }
except
on EStreamError do Result := False ;
{$IFDEF WIN32}
on EAccessViolation do result := False ;
{$ELSE}
on EGPFault do result := False ;
{$ENDIF}
end ;
finally
dfmStream.Free; { Free binary stream }
txtStream.Free; { Free text stream }
end;
end;
--
Regards
Ralph (TeamB)
===
Thank You!
Extremely!!!
Richard.
"Ralph Friedman (TeamB)" <ralphf...@email.com> wrote in message
news:VA.000007e...@della.garlin...
Use ObjectResourceToText.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.