Re: A buffer mapped to a file?



You could try a named pipe, if the program really just calls CreateFile and reads or write to the resulting handle, but as soon as a program tries to do something like query file size, set file pointer, or soforth, that will break. So that really tends to be program specific as to whether it will work.

The most compatible solution is to create a temp file on disk and delete it when done, I would imagine.

--
Ken Johnson (Skywing)
Windows SDK MVP
http://www.nynaeve.net
"rep_movsd" <rep.movsd@xxxxxxxxx> wrote in message news:1175105745.453461.126290@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi

Its quite simple to map a file to memory using CreateFileMapping()
and MapViewOfFile().

Now I need the converse....

Basically I have a buffer of data and need to feed it into an API
which expects a filename.

I can think of 2 ways of the top of my head, but I'm not sure about
the details.

1) Launch a process with redirected stdin / stdout , make the API read
from "CON:" or "\.\\Device\Console" or whatever and the parent process
will feed the data into the <stdin> of the launched process.

2) Make some type of FIFO or pipe... , but do such objects have names
that are within the filesystem namespace and will the ReadFile() API
cope with them? As far as I can recall in linux it was quite simple to
make a fifo right on the filesystem and feed arbitrary data via it
into any program that needed it as a file.

Any way to do this under Win32?

Regards
Vivek


.