Ç - 在内存中创建的文件 [英] C - create file in memory

查看:103
本文介绍了Ç - 在内存中创建的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在纯C写在这里的小程序。
我需要的是直接内存里创建一个文件(不是写在硬盘)
目前,我可以使用的fopen(FILENAME.TXT,WB)来写入文件。

I'm writing little program in plain C here. What I need is to create a file directly inside memory (not written on hard disk) Currently I can use fopen("filename.txt,"wb") to write to the file.

我知道,在linux下可以使用 fmemopen()。有没有为Win32类似的解决方案?

I know that in linux you can use fmemopen(). Is there a similar solution for win32?

推荐答案

您可以实现的东西亲近MapViewOfFile。
你应该为此使用Win32 API的是:

You could achieve something close with MapViewOfFile. Win32 API you should use for this are:

的CreateFile(.. 。)

的CreateFileMapping(.. 。)

MapViewOfFile(.. 。)

不要忘了取消映射并关闭文件映射一旦你完成。

Don't forget to unmap and close file mapping once you are done.

这篇关于Ç - 在内存中创建的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆