How Use ShellExecute with a CMemFile

Hello,

I need to store files of various types (such as .doc, .xls, .jpg, .pdf,
..wmv, ...) in a database.  Upon retrieval of such a file I have the file as
data in memory in a CMemFile.  I need to then "display" the file in the
aproriate application.  If I were to write the CMemFile to disk and create
an actual file I could then, of course, use ShellExecute() to launch , say
Word to display a .doc file.

However, I would much prefer to avoid the overhead of writing the data to an
actual file and then dealing with having to detect when the User is done and
cleaning up the file I had written.

I cannot find any documentation on how to "point" ShellExecute() to a
CMemFile - can anyone suggest how this can be done?

I don't want to be more restrictive in my question than is necessary so I
suppose the more general question would be "If I have a representation of a
file in memory how can I get it displayed without having to 1st write a
temporary file"?

Thanks for your help.

Al Koch
AlKoch@MyRealBoxREMOVEALLTHESECHARS.com


0
AlKoch (10)
2/19/2005 2:03:15 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
981 Views

Similar Articles

[PageSpeed] 45

I would just write it to disk.  There may be a way to do it the other way 
but I wouldn't know how.  A file application is hardcoded to read a disk 
file, I'm not sure there's any way to redirect it to a memory file... plus 
web browsers download files to view and they write out the files they 
download to disk so I don't think its inappropriate.

One way to deal with the cleanup of temp files is to put the file paths on 
an array and then at shutdown of your app clean up the files.  the external 
viewer may have it locked you may have to dream up more complex scheme (like 
keeping track of it and cleaning it next time your app runs, or keeping in 
your own temp folder where you know you can delete anything in there, etc.).


"Al Koch" <AlKoch@MyRealBox.com> wrote in message 
news:OvbOyciFFHA.936@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> I need to store files of various types (such as .doc, .xls, .jpg, .pdf,
> .wmv, ...) in a database.  Upon retrieval of such a file I have the file 
> as
> data in memory in a CMemFile.  I need to then "display" the file in the
> aproriate application.  If I were to write the CMemFile to disk and create
> an actual file I could then, of course, use ShellExecute() to launch , say
> Word to display a .doc file.
>
> However, I would much prefer to avoid the overhead of writing the data to 
> an
> actual file and then dealing with having to detect when the User is done 
> and
> cleaning up the file I had written.
>
> I cannot find any documentation on how to "point" ShellExecute() to a
> CMemFile - can anyone suggest how this can be done?
>
> I don't want to be more restrictive in my question than is necessary so I
> suppose the more general question would be "If I have a representation of 
> a
> file in memory how can I get it displayed without having to 1st write a
> temporary file"?
>
> Thanks for your help.
>
> Al Koch
> AlKoch@MyRealBoxREMOVEALLTHESECHARS.com
>
> 


0
river.ross (102)
2/19/2005 5:59:22 AM
Hi River,

Thanks for the reply.  It's not what I wanted to hear so I'm hoping
somebody's got a clever way to do this.

Your comment about browsers is very interesting though because that's
exactly what I've been wondering about since, let's say, IE is essentially
dealing with the same problem I am.  That is, it is "obtaining" a file as
data in RAM and needs to launch an app to "display" it.  I had previously
done some quick & dirty experimenting and got some indication that when IE
downloads and "plays" a video or a Word doc that it writes the file (under
XP) to the C:\Documents and Settings\username\Local Settings\Temporary
Internet Files folder but I never saw a .PDF that was downloaded appear
here.  So I'm not sure I "proved" to myself that even IE has to write a temp
file 1st.  Even if it does I could see an argument that says that it does so
to cache the file to speed up the next access of the file not because the
technology (ShellExecute() ?) isn't available to play the file directly from
RAM.  So, are how confident are you that 1) IE always writes a temp file and
2) it dos so because there's nothing in the API to allow it to "play from
RAM"

Also, thanks for the suggestion son how to claen up the temp files.

Thanks again for your help.
Al


0
AlKoch (10)
2/19/2005 6:31:37 PM
The IE example with PDF file may be a little different becuase that's a 3rd 
party active X control embedded in the browser.  It may have its own 
seperate caching implementation?

It seems weird that there could be a generalized way to redirect all these 
different apps to another process's private memory space.

"Al Koch" <AlKoch@MyRealBox.com> wrote in message 
news:u7D9EFrFFHA.3732@tk2msftngp13.phx.gbl...
> Hi River,
>
> Thanks for the reply.  It's not what I wanted to hear so I'm hoping
> somebody's got a clever way to do this.
>
> Your comment about browsers is very interesting though because that's
> exactly what I've been wondering about since, let's say, IE is essentially
> dealing with the same problem I am.  That is, it is "obtaining" a file as
> data in RAM and needs to launch an app to "display" it.  I had previously
> done some quick & dirty experimenting and got some indication that when IE
> downloads and "plays" a video or a Word doc that it writes the file (under
> XP) to the C:\Documents and Settings\username\Local Settings\Temporary
> Internet Files folder but I never saw a .PDF that was downloaded appear
> here.  So I'm not sure I "proved" to myself that even IE has to write a 
> temp
> file 1st.  Even if it does I could see an argument that says that it does 
> so
> to cache the file to speed up the next access of the file not because the
> technology (ShellExecute() ?) isn't available to play the file directly 
> from
> RAM.  So, are how confident are you that 1) IE always writes a temp file 
> and
> 2) it dos so because there's nothing in the API to allow it to "play from
> RAM"
>
> Also, thanks for the suggestion son how to claen up the temp files.
>
> Thanks again for your help.
> Al
>
> 


0
river.ross (102)
2/20/2005 8:29:15 AM
"River Ross" <river.ross@sbcglobal.net> wrote in message
news:vTXRd.14897$D34.1845@newssvr12.news.prodigy.com...
> The IE example with PDF file may be a little different becuase that's a
3rd
> party active X control embedded in the browser.  It may have its own
> seperate caching implementation?
>
> It seems weird that there could be a generalized way to redirect all these
> different apps to another process's private memory space.
>
> "Al Koch" <AlKoch@MyRealBox.com> wrote in message
> news:u7D9EFrFFHA.3732@tk2msftngp13.phx.gbl...

Hi River,

Thanks for your additional input.  Your comments on the PDF probably explain
why I didn't see a temp file being created.  Looks like I'm just gonna have
to write a temp file to disk!

Thanks again,
Al.



0
AlKoch (10)
2/23/2005 5:37:27 PM
Reply:

Similar Artilces:

sending mail using an alias email address
We are using Exchange Server 2007 with Outlook 2007 clients. I have several email addresses listed under my mail account on the Exchange Server for which I "receive" email. However, the server will not allow me to "send" email using any of these email addresses - as it only allows me to send using the primary address for my email account. I get a message saying "You are not allowed to send this message ... on behalf of another sender without permission to do so." What settings do I need to change on the Exchange Server so that it allows Outlook 2007 ...

using parameters
I have a form which the user selects the BlockNo. The other information that is entered in the form is : 1) NoOfRecordedTrees - RT 2)NoOfSurroundingTrees - ST When the BlockNo is entered, a query runs which picks up fertiliser rates for this Block for all sectors within that block. With RT and ST - it should do a calculation such that it uses Rate/ sector * (RT+ST) to find how much fertiliser is needed for each sector in each block. I would like to add a column to the existing query showing FertiliserAmt using these parameters. How do I specify them within the query. Thanks for your great...

how can i set up my pop and smtp account using proxy server in ou.
"Abhishek" <Abhishek@discussions.microsoft.com> wrote in message news:90EE645B-97D9-4145-A368-E26743C547F9@microsoft.com... You'll need instructions from your ISP. -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP Stockholm Consulting Group/KSG http://www.scgab.com Microsoft OneNote FAQ: http://home.hawaii.rr.com/schorr/computers/onenotefaq.htm **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! ...

Finding all queries which use a table
Hi, Does anyone know of a tool that can scan all queries in a database and find if a certain table is used? I have a table called tblCustomerRollup which is old and outdated. I want to see which of the 500 queries in my database use this table without opeing every single one of them? Thanks, -- Chuck W Chuck Sounds like a variation on Search/Replace. Try searching online for "Database Documenter" as a starting point. A couple of the commercial tools I've used include FMS, Inc.'s Total Access Analyzer and Black Moshannon's Speed Ferret. There are a lot of fr...

Re: Using alias address
Brian Tillman wrote: > Vince <vinresp*@swhome.com> wrote: > > >>We use an exchange server at work for e-mail. I have set up an alias >>that I use for receiving mail but I wanted to use the alias for >>sending all the mail as well. I was told that it cannot be done in >>exchange but I can use a POP server. > > > I don't believe that's always true. For example, I have several accounts in > Outlook where I work, all within the same profile. Only one of those > accounts, the Exchange account, uses my work address. The ot...

Can Outlook 2003 use MSN Messenger INSTEAD of Windows Messenger?
I didn't get an answer to this question last week so I'm re-posting... I recently purchased a new computer (Windows XP Home Edition w/SP2) and loaded up all of the available updates to the OS, Internet Explorer, etc. Next, I installed Office 2003 Professional. I disabled Messenger integration with Outlook 2003 as discussed in other posts here. Next I installed MSN Messenger 6.2 and it seemed to run properly as a stand-alone application. So I re-enabled Messenger integration on Outlook 2003. The next time I booted up and ran Outlook, the Messenger icon appeared in the taskbar...

Creating Contacts For Accounts Using...
Hopefully as Microsoft CRM matures, many small time saving features will be added. One that should be a priority is the ability to add a new contact for an existing account using the common account information, i.e. address, phone number, web address, etc. Retyping the same company address in each time is not very productive. Thank you, Ed Podowski ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, f...

Scroll horizontaly with mouse, create same system used to scroll .
Hi, I think it would be great if mouses adopted a second scroll button, for horizontal scrolling, just like the vertical one .... Indeed, when you work with wide Excel spreadsheets, you can easily scroll down but to scroll from left to right or vice-versa, you have to use the scroll bar or arrows and it's annoying... So, am I a millionnaire yet??? Hi Frederic, > I think it would be great if mouses adopted a second scroll button, for > horizontal scrolling, just like the vertical one .... Indeed, when you work > with wide Excel spreadsheets, you can easily scroll down b...

outlook in sub-domain to set use root-domain question!!!
Dear Sir Please see below more details,(We are using special railway line between Head office in Taipei and branch office in Tao-Yuan) Head office in Taipei: aaa.com(Root domain) Dc server * 2(One of it is GC Server), Front-End Exchange 2003 *1, Back-End Exchange 2003 * 2(One is named mail1, another is named mail2 ) Branch office in Tao-Yuan: bbb.aaa.com(sub-domain) Dc Server *1(No GC Server,No Exchange Server) After using ADMT v3 Tool, when I transfer an account from root named aaa.com(ou) to bbb.aaa.com. After I ins...

Outlook first use
Hi, when I open Outlook in a workstation for the first time, Outlook open setup and ask user to create a new profile. I have a utility to create profile automaticaly and this setup is deleting existing profile. Is it possible to Outlook don�t ask to create a new profile for the first time? Tks. Alex ...

Online Restore using NT Backup has no edb.chk or edb.log files
I have a single site with four servers running Exchange 5.5 SP4 on NT4 SP6a. I am using an internal 35/70 Compaq DLT. When I back up two servers at the same time using online method, I am missing the edb.log and and edb.chk files when trying to restore the db's. Is there a known issue for this? Thanks, Jim When you make online backup, you are backing up the database content perse, the logs files will be skipped because ntbackup cannot back up open files. I recomend you to adquire a third party backup software with open files and exchange database options, like Veritas to ensu...

Calculating Correlation using arrays
I have a sheet full of data for many products in chronological order. Column A is Date of manufacture Column B is time of manufacture Column C is the product Column D is a measurement from the automatic control system Column E contains occasional manual measurements for calibratio checks Up till now I have split the data out by grade and checked calibratio using pivot tables and also checked slope and offsets. After gainin exposure to all kinds of clever functions via this board I now wonde whether it would not be possible to automate these checks in some way ie on a separate sheet I list t...

can I use 11 x 14 paper in office documents?
Is it possible to use a larger sheet of paper when using publisher? Yes. First select the paper size in the Printer Setup. -- Don Vancouver, USA "Prairie Inn" <Prairie Inn@discussions.microsoft.com> wrote in message news:FC032907-D965-4DE9-891D-40DF9C6E9C8C@microsoft.com... > Is it possible to use a larger sheet of paper when using publisher? If your printer can handle it, yes. -- JoAnn Paules MVP Microsoft [Publisher] ~~~~~ How to ask a question http://support.microsoft.com/KB/555375 "Prairie Inn" <Prairie Inn@discussions.microsoft.com> w...

use excel to create PP slides?
I'm not sure if this is possible but I have a list of information in an excel table and I'd like to auto matically generate a slide for each row of data. for instance, I have a list of products and each product is on it's own row with 6 product features in the following columns. How can I take that info from excel and create a features slide for each product using the information from the following columns. I don't mind cutting and pasting the list - it doesn't have to be fully automatic but as I have over 1000 products I desperately don't want to reype ...

Using BGInfo Command Line Parameters
I've read the Help file in BGInfo - but can't figure out how to use Command Line Parameters. When I click on my startup icon, I would like to invoke certain parameters. The line I came up with is: "C:\Program Files\BGInfo\BgInfo\Bginfo.exe /timer:99 /popup /taskbar /rtf:C:\DATA\BGINFO /nolicprompt" Obviously, this is wrong. My Target line reads: "C:\Program Files\BGInfo\BgInfo\Bginfo.exe" My Start in line reads: "C:\Program Files\BGInfo\BgInfo" Please help me by telling me what, exactly, should go in each line. I would also like t...

Creating and pasting using VB
I need to create an email and paste a current selection in microsoft excel using visual basic. I have just started to work on this so I don't know what all I have to include. If I need mapi add-ins or anything else added please let me know. I already have the sub routines set to copy the data that I need out of excel but now I need to email this data automattically. Any help would be very helpful. Thanks, Matt ...

Use Your Brain
All, Here is an example of what extreme boredom can do to a person. Excel 2002 / Window XP :D Have fun. Attachment filename: use your brain.zip Download attachment: http://www.excelforum.com/attachment.php?postid=386422 --- Message posted from http://www.ExcelForum.com/ Ken, Very cute. You must have a lot of free time on your hands. John "Pyball" <Pyball.ynt5z@excelforum-nospam.com> wrote in message news:Pyball.ynt5z@excelforum-nospam.com... > All, > > Here is an example of what extreme boredom can do to a person. > > Excel 2002 ...

Can Entourage be used to access Google Groups
I am in the process of switching from PC to Mac. In Entourage, I see this news server. Can I get some of my newsgroups in Google Groups to show on Entourage or Mac Mail? Responses off group will be welcome if I have asked something everyone except me knows. Thanks, Michael Plog On 1/31/10 3:25 PM, Michael Plog wrote: > I am in the process of switching from PC to Mac. In Entourage, I see this > news server. Can I get some of my newsgroups in Google Groups to show on > Entourage or Mac Mail? > > Responses off group will be welcome if I have asked something e...

Publish A Workbook Onto The Web, Then Access Using My Web Browser.
How do I access my spreadsheet, or workbook, on the web once I've saved it as a webpage from the file menu? I've found that even though I've save my workbook as a webpage, it does not have an http:// address which I can type in my web browser to access the workbook from my home computer or from a remote computer. Should I have to sign up with an http:// service provider or can this all be done from using Microsoft Office XP without going through a third-party? -- sigmad You have to have a website first of all, otherwise, where do you want to host this page? "sigmad&q...

Error Message using Personal Folders Back-up
I recently downloaded and installed the Personal Folders Back-Up program into my Outlook 2000. I have it set to back up my Personal folder to a Zip drive when I exit Outlook. When the I exit the program I keep getting the following message "Cannot copy outlook: The process cannot access the file because another process has locked a portion of the file." What do I need to do to get this to work properly? I would like to be able to back up my Personal folder without exporting each subfolder to the zip drive individually. I also tried backing up to other locations with the sam...

Using old templates from Publisher 97
Hi, A few years ago I used Publisher 97 and created a Raffle Ticket and also an event ticket using Mail Merge to automatically number the tickets from an Excel Document I made. Now I have Publisher 2002 on my computer and it seems to be so much more professional and doesn't have many of the templates that I used to use in "Specialty Items", such as, Bookmarks, Gift Tags, Door Hanger, Raffle Ticket, etc. I was wondering if it is possible to get these templates in my new Publisher 2002, if not, is it possible to have both versions on my computer so I can use the specialty...

using addrress books to sort incoming mail
I use address books to sort incoming mail. An odd thing: depending on how the sender's name comes across, it doesn't get caught by the filter (amd moved to the "Family Mail" Folder I have set up. for example: my mom and dad's email (from momanddad@somedomain.com) comes as from that address. However, in my contacts, they are listed by their names: John and Mary Smith, with momanddad@somedomain.com as their email address and John and Mary Smith as the display name. What have I done wrong? TIA 1. The big ONE - failed to post your version of Outlook. Rules operate at ...

Save single worksheet from workbook using the sheet name?
Gday, I have had a search through some of the previous questions and I cant quite find what I am looking for, I have a master sheet which I split into seperate sheets using one of Debra Dalgleishs macros all works fine. However my next step is to save each of these sheets into seperate folders using the individual sheet name. As ever I hope this isnt too muddled a question! Any help would be greatly appreciated TIA Ajay Ajay, You need to copy it to its own workbook and save that Worksheets("Sheet1").Copy ActiveWorkbook.SaveAs Filename:= "myfile.xls" -- H...

Recently used file list
Does anyone know if the size of the list can be increased from the default of 9? Thanks Tools/Options/General allows you to change the recently viewed size, but is pretty clear that the maximum is 9. >-----Original Message----- >Does anyone know if the size of the list can be increased >from the default of 9? > >Thanks >. > In xl2k and xl2002 (not sure about xl97), when you do a file|open, you'll see a History button in the left hand frame. Maybe you could use that to see more. Maria wrote: > > Does anyone know if the size of the list can be increased...

Using + in formulas
Some individuals at my office use a + in front of cells when they ar putting calculations within a cell. E.g. =+a1-b2 versus =a1+b2. First why do they do this? Second, in a recent spreadsheet, I came across the formul =AVERAGE(+X:Y). The result of this formula gave me the average of onl the first cell within the range (i.e. +X... the result of the cell wa simply X). Second, why is this? Basically, what does the + do in the front of formulas and what benefi does it provide? I tried to search Excel help and even tried to find the answer i Google to now avail. Thanks in advance! -- kylesi ...