troubleshooting Question

VB Virtual Drive (DefineDosDeviceW)

Avatar of QDS_NET
QDS_NET asked on
Visual Basic Classic
3 Comments1 Solution899 ViewsLast Modified:
Im trying to get my program to create a virtual drive just like the subst command. I don't really like the subst command, and I hate shelling. Better off using API I think.

Here is what I have worked out so far, but I still can't get it to work!

(I know im close!!!)


'Constants thanks to AlonHirsch!!!
 Const DDD_EXACT_MATCH_ON_REMOVE As Long = &H4
 Const DDD_NO_BROADCAST_SYSTEM As Long = &H8
 Const DDD_RAW_TARGET_PATH As Long = &H1
 Const DDD_REMOVE_DEFINITION As Long = &H2

Private Declare Function DefineDosDeviceW Lib "kernel32" (dwFlags As Long, DeviceName As Long, PathName As Long) As Boolean


Private Sub Command1_Click()
   Dim namex As String
   Dim namey As String
   
   namex = "v"
   namey = "c:\"
   
   'make the virtual drive
   MsgBox DefineDosDeviceW(DDD_RAW_TARGET_PATH, VarPtr(namex), VarPtr(namey))
   
   
   'break the virtual drive
   MsgBox DefineDosDeviceW(DDD_REMOVE_DEFINITION, VarPtr(namex), VarPtr(namey))
   
End Sub



Cheers,
Ben
(yes, laugh at the newbie...)
ASKER CERTIFIED SOLUTION
modulo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros