Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

delphi - Opening a file in a memory stream with the correct program

My application saves files to a database field. It will take file types of .pdf, .doc, .xls, and .html (for example) save them to the table, so I can later extract the value and open it as a file.

Currently, I am saving a file (type pdf in this example) to a Varbinary field in a SQL table I created. I am then reading that file back into a memory stream using the following code:

TBlobField(FieldByName('FileData')).SaveToStream(FileData);

I can save this to desktop as a pdf just fine. However I would like to open it directly from the memory stream with the appropriate application (in this example adobe acrobat). I could write this to file first and then open it with shellexecute but i would rather open it directly. How would I go about accomplishing this? Any help would be greatly appreciated, I've looked all over and can only find examples using shellexecute to open Filepaths. ShellExecuteEx claims the lpFile can be set to an object but i haven't had any luck getting it to work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You cannot do that. Memory is private to a process. When the Acrobat process executes, it cannot read your memory. You will have to save to a file and ask Acrobat to open that, or host a PDF viewer component in your process.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...