Quantcast
Channel: Reboot.pro
Viewing all articles
Browse latest Browse all 6812

.NET API and creating/unmounting a RAM Disk

$
0
0

Hello,

 

I came across ImDisk there other day and wanted to use it create a RAM Disk using 15 GB of memory, but I am having a hard time trying to recreate the following command line in C# (or VB, if you don't know C#).

 

imdisk -a -s 15000M -m R: -p "/fs:ntfs /q /y"

 

I have found a sample that used the following code, but I am not sure what the 52428800 represents. I thought it might be bytes, but it didn't seem to be. How do I create a 15 GB RAM Disk?

 

ImDiskAPI.CreateDevice(52428800, 0, 0, 0, 0, ImDiskFlags.DeviceTypeHD | ImDiskFlags.TypeVM, null, false, driveLetter, ref deviceID, IntPtr.Zero);

 

The sample I found also had the following call, but I am not sure if I need it. All I want to do is create a new drive ®, format it and then copy game files to it.

 

ImDiskAPI.CreateMountPoint(mountPoint, deviceID);

 

Also, when I tried to use RemoveDevice to unmount the "R:" drive, using either the MountPoint name or DeviceID, I get the following error.

 

"An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in ImDiskNet.dll"

 

When I tried to call RemoveDevice using the ForceDismount flag, the drive appears to be unmounted, but I still see it in Windows Explorer, yet can't access it, and the only way to remove it is to reboot. How do I properly unmount a RAM Disk and remove it from Windows Explorer like the Control Panel app does? I don't care about saving the data that's on it.

 

I would appreciate any help you can provide.


Viewing all articles
Browse latest Browse all 6812

Trending Articles