Thread: File handle to a memory location

  1. #1
    Registered User
    Join Date
    Sep 2001

    File handle to a memory location

    I'm working with a pair of third party APIs trying to play a video straight (SMK format) out of a compressed library (MPQ format). I can use the mpq api to extract the video out of the library into a memory buffer, but the smk api requires a file handle (like that obtained from CreateFile) to point to the file.

    Is there any way I can use CreateFile or anything else to obtain a similar handle to a block of memory, rather than a place on the hard disk?

    Of course, I could write the buffer to a temporary file on the disk before playback, but these videos are to be used in a game and I'd like to avoid disk I/O as much as possible.

    Thanks a lot.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Thanks, I'll give that a try. I'll probably have to implement a pipes system alongside a temp file method though, apparantly win9x doesnt support creating named pipes, fortunate that 9x seems to be a dying breed.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    You could try using this in your call to CreateFile() before you go to the trouble of implementing a pipe system.

    FILE_ATTRIBUTE_TEMPORARY - The file is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because often the application deletes the temporary file shortly after the handle is closed. In that case, the system can entirely avoid writing the data. Otherwise, the data will be written after the handle is closed.
    I don't see why you would need named pipes to implement a pipe system, anonymous pipes should do just fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM