Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Streams and Memory files

Posted on 1997-06-09
9
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

705 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