PureBasic Windows: Creating a virtual drive.

Just starting out? Need help? Post your questions and find answers here.
fenyctis
User
User
Posts: 21
Joined: Sat Sep 10, 2005 9:08 pm

PureBasic Windows: Creating a virtual drive.

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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\
fenyctis
User
User
Posts: 21
Joined: Sat Sep 10, 2005 9:08 pm

Post 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.
Effigy
User
User
Posts: 35
Joined: Fri Apr 25, 2003 5:40 pm
Location: Canada
Contact:

Post 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.
Derek Gavey
- PB Newbie -
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post 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...
Good programmers don't comment their code. It was hard to write, should be hard to read.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post 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 
fenyctis
User
User
Posts: 21
Joined: Sat Sep 10, 2005 9:08 pm

Post 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.
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post 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
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Search forum option returned this for me...

viewtopic.php?t=14910
Image Image
fenyctis
User
User
Posts: 21
Joined: Sat Sep 10, 2005 9:08 pm

Post 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...
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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?
Tranquil
uweb
User
User
Posts: 98
Joined: Wed Mar 15, 2006 9:40 am
Location: Germany

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

Post 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).
Please pardon my English, my native tongue is German.
Post Reply