I am not looking for a code that invokes a command line utility, which does the trick. I am actually interested to know the API used to create a RAM disk.
EDIT
Motivation: I have a third party library which expects a directory name in order to process the files in that directory in a certain way. I have these files zipped in an archive. I wish to extract the archive into a RAM disk and pass the third party the path to the respective directory on that RAM disk. As you can see, memory mapped files are of no use to me.
There is no API to create a RAM disk per se. You need to write your own device driver which presents a new disk to the system, and make that device driver work with allocated memory.
EDIT (after the OP’s edit)
What you are trying to do would normally be done using the ‘temp’ directory, which is supposed to reside on the fastest disk available in the system. So, a system which already has a RAMdisk will probably have its temp environment variable already set to point to a folder on the RAMdisk, and systems without a RAMdisk would simply take the performance penalty, it is their problem.
Now, if for some reason you cannot rely on the presence of a RAMdisk on a system, AND you absolutely need the fastest performance possible, then I see no option but to install a third-party (perhaps freely downloadable, perhaps even open source) RAM disk, use it temporarily, and then uninstall it. But that’s very clunky.