Page 1 of 2

PureBasic Windows: Creating a virtual drive.

Posted: Thu Sep 22, 2005 2:00 pm
by fenyctis
Is it possible to create a virtual drive with PureBasic, so it appears in Windows as a new drive with its own drive letter and I can handle the further stuff to insert in that virtual drive?
Thanks a bunch in advance.

fenyctis

Posted: Thu Sep 22, 2005 3:04 pm
by Trond
This only works under Windows 9.x:

This dos command (can be run with RunProgram) creates a virtual drive r: that corresponds to a folder on c:\

subst r: c:\myfolder\subfolder\

Posted: Thu Sep 22, 2005 3:08 pm
by fenyctis
Not really my idea. I want to create a virtual drive--rather in 2000/XP than in 9x--and then fill it in myself. Not a folder, but data I will provide myself.

Posted: Thu Sep 22, 2005 3:13 pm
by Effigy
Just a correction the subst command is still available in 2000/XP I use it all the time for mimiciking server map drives in some of my software.

I'd be very curious to see how a virtual drive can be acomplished as well.

Posted: Thu Sep 22, 2005 3:34 pm
by traumatic
Effigy wrote:Just a correction the subst command is still available in 2000/XP
DefineDosDevice_() should do the trick as well. ;)

Anyway, in order to create real virtual drives you have to delve a little
deeper into driver development.

Microsoft provides a ramdisk sample driver containing sourcecode, don't
know if this helps (DDK needed).

On the other hand... driver development in PureBasic? Hmm...

Posted: Thu Sep 22, 2005 7:15 pm
by TerryHough
Is this what you are looking for? I have seen this described as a "virtual"
drive.

Code: Select all

NR.NETRESOURCE

LocalName.s = "Q:"                      ; Change to your desired device name
RemoteName.s = "\\TERRY\C:\PUREBASIC"   ; Change to your desired path, local or remote

NR\dwType =  #RESOURCETYPE_DISK
NR\lpLocalName  = @LocalName
NR\lpRemoteName = @RemoteName

; Make the connection -------------------------------------
; ------ (ptr to NETRESOURCE structure, password, username, flag = 0 or #CONNECT_UPDATE_PROFILE)	
If WNetAddConnection2_(@NR,"","",#Null) = #NO_ERROR
  ; Have a look... go on...
  MessageRequester ("Cool!", "Go verify that the drive is now in My Computer" + Chr(10) + "Then come back and click OK", #MB_ICONINFORMATION)
Else
  MessageRequester ("Drat!", "Couldn't connect -- check paths and/or network", #MB_ICONERROR)
EndIf
;
;  Do whatever
;
; Remove assigned connection ------------------------------
; ------ (ptr to resource name, flag - 0 or #CONNECT_UPDATE_PROFILE, #TRUE (force disconnect) or #FALSE (fail if open files or jobs)
If WNetCancelConnection2_(@LocalName,0, #True) = #NO_ERROR 
  MessageRequester ("Cool!", "Disconnected successfully", #MB_ICONINFORMATION)
Else
  MessageRequester ("Drat!", "Couldn't disconnect -- remove connection manually", #MB_ICONERROR)
EndIf 
End 

Posted: Thu Sep 22, 2005 9:55 pm
by fenyctis
Not really, thank you anyway though. I would like to create a virtual drive, and then when it is accessed, I want to send through the index of a fictional folder.

Posted: Fri Sep 23, 2005 7:29 am
by Kukulkan
Hi fenyctis,

I really understand your question. I need the same thing to recognice what file a user try's to find on my drive and then react on my way (give him the file or an own generated error etc.). I will be able to generate the data that is returned by the filesystem.

The MS-example for the "ramdisk sample driver" postet by traumatic should be nearest of what we both want.

Kukulkan

Posted: Fri Sep 23, 2005 10:42 am
by Trond
Kukulkan wrote:Hi fenyctis,

I really understand your question. I need the same thing to recognice what file a user try's to find on my drive and then react on my way (give him the file or an own generated error etc.). I will be able to generate the data that is returned by the filesystem.

The MS-example for the "ramdisk sample driver" postet by traumatic should be nearest of what we both want.

Kukulkan
Theoretically easy, just write a file system driver. :roll:

Posted: Fri Sep 23, 2005 2:54 pm
by blueznl
i seem to recall a dll mentioned somewhere, that would provide such a device available from within a programming language... was it mentioned here on the forums?

Posted: Fri Sep 23, 2005 3:43 pm
by Kukulkan
i seem to recall a dll mentioned somewhere, that would provide such a device available from within a programming language...
Whohahhh :shock: This would be nice... Can someone remember this? I searched such a DLL but never found something. Maybe I searched with the wrong words?

Kukulkan

Posted: Fri Sep 23, 2005 4:20 pm
by Paul
Search forum option returned this for me...

viewtopic.php?t=14910

Posted: Sat Sep 24, 2005 11:14 am
by fenyctis
This might be useful. Do you think it's possible to fill it with fictional data? I don't know much about filesystems...

Posted: Sat Sep 24, 2005 11:18 am
by Tranquil
fenyctis wrote:This might be useful. Do you think it's possible to fill it with fictional data? I don't know much about filesystems...
I think you are messing with a very difficult topic. Maybe you should start with something easier?

... but i am not the only one ... (John Lennon)

Posted: Tue Sep 19, 2006 12:37 pm
by uweb
I have the same problem and saw the driver a long time ago, but i like to make a quick solution - it should WORK IN MEMORY.
Actual i have some ideas :

1. Make a FTP-Server and mount it in Windows (2000/XP/... in Explorer)
But this is only a Link and not availabel by File-Open.

2. Use my own FTP-Server and work with WebDrive.
But this costs monye for me and all they wont to use my software.
http://www.southrivertech.com/products/ ... index.html

3. Change the OS (or have a second PC) and use a new Linux with Fuse - Filesystem in Userspace
http://fuse.sourceforge.net/
there are some solutions (FTP also) and it is posible (may not for me) to make a own driver (direct connecting to a PB-App.)
It is a hard way.

4. Use http://www.acc.umu.se/~bosse/httpdisk-3.zip also on http://www.acc.umu.se/~bosse/
One minute ago i saw (maybe) the key for this
http://www.purebasic.fr/english/viewtop ... filesystem - 4. Thread


Hope someone can use a part of this (and will share his work).