Solved

Streams and Memory files

Posted on 1997-06-09
9
193 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
Comment Utility
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
Comment Utility
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
Comment Utility
For what purposes do you need just FILE structure? What fields do you use and how?
0
 
LVL 4

Accepted Solution

by:
mbhakta earned 50 total points
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:401980
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now