[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Streams and Memory files

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
401980
Asked:
401980
  • 4
  • 4
1 Solution
 
mbhaktaCommented:
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
 
401980Author Commented:
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
 
AVaulinCommented:
For what purposes do you need just FILE structure? What fields do you use and how?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
mbhaktaCommented:
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
 
401980Author Commented:
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
 
mbhaktaCommented:
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
 
401980Author Commented:
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
 
mbhaktaCommented:
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
 
401980Author Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now