Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Streams and Memory files

Posted on 1997-06-09
9
Medium Priority
?
206 Views
Last Modified: 2013-11-20
I use a libary that convert file formats but it only use file handles (FILE) as parameters and I dont want to write it as a file but to memory.Are the any way I can send it a FILE parameter but let it write the data to memory so I can read it without writing a file first.The function I call look like this "BOOL SaveFile(FILE * OutFile)"Can I create a memory file and send it's handle to the function? How do I do that?
0
Comment
Question by:401980
  • 4
  • 4
9 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302034
There are several ways of doing this :
If you want to do it the MFC way , try using the CMemFile which has been derived from CFile itself.

If you want to use native SDK try browsing the MSDN or VC++ CD for memory mapped files. The ftp.microsoft.com used to have a native C++ sample demonstrating mem-mapped file i/o which was in MMFILE.EXE check it out if it still exists.
0
 

Author Comment

by:401980
ID: 1302035
The m_hFile data member of the CFile class gives the variable of type UINT and I need the FILE structure used in I/O streams.I thought of using CMemFile but how do I get a FILE Structure
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1302036
For what purposes do you need just FILE structure? What fields do you use and how?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
mbhakta earned 100 total points
ID: 1302037
As I said , please download the MMFILE.EXE from the Microsoft sit e and see how it is implemented. It not a real nice idea to reject the answer without proper investigation.
0
 

Author Comment

by:401980
ID: 1302038
The Libary that I use take the FILE struct as a parameter and write the data to the file. I dont now what it is using of the FILE structure.How the lib works is I open a bitmap file and send the the FILE structure to it as parameter. Then I create another file but with a jpeg extention and call another function that requir a FILE structure as parameter (that is now the file that I just created) and it use that structure to write a JPEG file. But I dont want to create a file on disk but in memory so I can send it as a data stream. On the long run I want to convert a BMP file that are in a CLongBin class to jpeg and put that also in a CLongBin class with out creating files. The only way I can see how I can do that are to create memory files or do you have better way or libary or code that can convert BMP to JPEG.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302039
There is a freeware code from the JPEG group on the net. This code is the infrastructure of the JPEG file. It supports conversion from favourite formats like BMP, GIF etc. to JPG and vice versa. Try exploring the code in there. Also as I pointed out MMFILE example ( WHICH YOU HAVE BEEN IGNORING) would be a way to solve your aches, the CMemoryMappedFile is derived from CMemFile which is inturn derived from CFile. If you are not interested in following some instructions I have been telling you , then Adios!!!

0
 

Author Comment

by:401980
ID: 1302040
I looked at the memfile (The first time you wrote about it) but how can I get a FILE struct from the CMemoryMappedFile (memfile)to send to the lib function that requir a pointer to a FILE struct?I have looked at the JPEG freeware code on the net but it looks to complicated to use.Sorry if you think I ignore your help because I think this is an excelend system helping people and I would not ignore your help.  
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302041
If you use CFile you won't need FILE structure anymore. CFile is a MFC replacement for FILE. You can pass CFile* as a parameter to the functions from hereon. Check for samples on the VC++ CD to see the integration issues.
0
 

Author Comment

by:401980
ID: 1302042
It does not work. The function return FALSE. But it does not sound write to send a pointer of CFile while it wants a pointer to a FILE struct.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question