Jump to content











Photo
- - - - -

methods in Visual Basic

visual basic vb.net coding imdisk programming

  • Please log in to reply
5 replies to this topic

#1 Amerigoware

Amerigoware
  • Members
  • 4 posts
  •  
    United States

Posted 28 August 2013 - 04:54 PM

I am trying to use imDisk in a vb 2010 application. I imported the appropriate .dll and found code to create a virtual drive, but not how to format it. 

When my program opens, it needs to create the drive and format it. On close; it needs to unmount/destroy/dispose the drive and any files added to it during the use of my program.



#2 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1398 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 28 August 2013 - 05:05 PM

I am trying to use imDisk in a vb 2010 application. I imported the appropriate .dll and found code to create a virtual drive, but not how to format it. 

When my program opens, it needs to create the drive and format it. On close; it needs to unmount/destroy/dispose the drive and any files added to it during the use of my program.

 

Unfortunately, ImDisk API has no method for formatting virtual disks. You could search for another library somewhere that might have that feature.

 

I assume that you want to create a virtual disk backed by memory of some kind. That is, not a virtual disk that exposes an image file directly as a virtual disk, but rather keeps disk contents in memory. In case you are creating a memory backed virtual disk, you could pre-load the virtual disk with an already formatted image file. To do that, you specify the image file path and device type "virtual memory" in the method call that creates the virtual disk.

 

The image file could be a small one so that you do not need to store a large image file for this purpose. You could then expand the size of the virtual disk later after it has been created (this requires NTFS filesystem on the virtual disk image).



#3 Amerigoware

Amerigoware
  • Members
  • 4 posts
  •  
    United States

Posted 28 August 2013 - 06:26 PM

How do I do that? Here's what I have so far...

Private Sub MyApplicationLoad(sender as object, e as system.eventargs)Handles Me.Load
        Dim deviceID As UInt32 = UInt32.MaxValue
        CreateDevice(10485760, "X:", deviceID)
        CreateMountPoint("X:", deviceID)
End Sub

'create files from stream as necessary with program functions...

Private Sub MyApplicationClose(sender as object, e as system.eventargs)Handles Me.FormClosed
RemoveMountPoint("X:")
End Sub




#4 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1398 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 28 August 2013 - 07:02 PM

 

How do I do that? Here's what I have so far...

Private Sub MyApplicationLoad(sender as object, e as system.eventargs)Handles Me.Load
        Dim deviceID As UInt32 = UInt32.MaxValue
        CreateDevice(10485760, "X:", deviceID)
        CreateMountPoint("X:", deviceID)
End Sub

'create files from stream as necessary with program functions...

Private Sub MyApplicationClose(sender as object, e as system.eventargs)Handles Me.FormClosed
RemoveMountPoint("X:")
End Sub

 

 

You do not need CreateMountPoint and RemoveMountPoint in your case. Just use CreateDevice with the drive letter parameter (like you already do) and then RemoveDevice when you want to remove the device.

 

Use an overload to the CreateDevice method that takes an image file path as parameter, for example this one:

http://www.ltr-data....b294df40883.htm



#5 Amerigoware

Amerigoware
  • Members
  • 4 posts
  •  
    United States

Posted 28 August 2013 - 11:07 PM

Public Shared Sub CreateDevice ( _
    DiskSize As Long, _
    ImageFile As String, _
    MemoryType As ImDiskAPI.MemoryType, _
    MountPoint As String, _
    ByRef DeviceNumber As UInteger _
)

Gets error at "MemoryType as mDiskAPI.MemoryType": "Type 'ImDiskAPI.memorytype' is not defined."



#6 Amerigoware

Amerigoware
  • Members
  • 4 posts
  •  
    United States

Posted 29 August 2013 - 01:11 AM

scratch the above. I realized that's not code I need to enter, but to draw from.

So I changed CreateDevice(10485760, "X:", deviceID) to 

CreateDevice(10485760, "Phantom", 0, True, "X:", deviceID)

But, now I don't get a drive at all. ..I made a image file named "Phantom" that is located in my "Debug" folder.







Also tagged with one or more of these keywords: visual basic, vb.net, coding, imdisk, programming

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users