|
-
Jan 6th, 2003, 10:42 AM
#1
Thread Starter
Fanatic Member
mapping a network drive
i have used the following code to map a network drive
VB Code:
Public Function m_mapDrive(LocalDrive As String, _
RemoteDrive As String, Optional UserName As String, _
Optional Password As String) As Boolean
'Example:
'MapDrive "Q:", "\\RemoteMachine\RemoteDirectory", _
'"MyLoginName", "MyPassword"
Dim NetR As NETCONNECT
NetR.dwScope = RESOURCE_GLOBALNET
NetR.dwType = RESOURCETYPE_DISK
NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
NetR.lpLocalName = Left$(LocalDrive, 1) & ":"
NetR.lpRemoteName = RemoteDrive
m_mapDrive = (WNetAddConnection2(NetR, UserName, Password, _
CONNECT_UPDATE_PROFILE) = 0)
End Function
that code works ok if i use it in win2000 Os but when i tried in a win98 Os. I get the following:
say i pass as a RemoteDrive drive the following path "\\machineName\dir1\dir2" i would expect to a new drive starting at dir2 (win2000 behaviour) but it maps a drive starting at dir1 which is the name of the shared directory of machineName
is there a work around?
thnks
-
Jan 6th, 2003, 10:49 AM
#2
Addicted Member
if both dir1 and dir2 are shared, or only dir1 is, try sharing only dir2....im guessing this gives win98 no option other than to share starting at dir2
-=[Ç¥ßè®Ìú§]=-
How many microsoft employees does it take to change a lightbulb? None, they simply define darkness as the new industry standard.
CAUTION: OVERCLOCKING A 386 TO 5Ghz MAY BE HAZARDOUS
-
Jan 6th, 2003, 10:51 AM
#3
Thread Starter
Fanatic Member
dir2 is inside dir1 and that is working on win2000 it is supposed to work on win98 too or isn't?
-
Jan 6th, 2003, 10:57 AM
#4
Addicted Member
i dont know, i dont have a network to try it on, so i guess all you can do is try
-=[Ç¥ßè®Ìú§]=-
How many microsoft employees does it take to change a lightbulb? None, they simply define darkness as the new industry standard.
CAUTION: OVERCLOCKING A 386 TO 5Ghz MAY BE HAZARDOUS
-
Jan 6th, 2003, 11:04 AM
#5
Frenzied Member
Here is a little bit different example how to connect or disconnect network drive. It uses windows connect and disconnect dialog boxes. See if you can use this
VB Code:
Private Declare Function WNetConnectionDialog Lib "mpr.dll" _
(ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Sub Command1_Click()
'Connect Network Drive
xyz = WNetConnectionDialog(Me.hwnd, 1)
End Sub
Private Sub Command2_Click()
'Disconnect Network Drive
xyz = WNetDisconnectDialog(Me.hwnd, 1)
End Sub
-
Jan 6th, 2003, 11:21 AM
#6
Thread Starter
Fanatic Member
even if u use these dialog boxes provide in win98 the results are the same that is if u want to map as a drive a path like \\machine\dir1\dir2 it only maps as a drive the \\machine\dir1 i suppose i m missing somthething but what?
-
Jan 6th, 2003, 11:52 AM
#7
Frenzied Member
OK, I see now. When you map drive the syntax is
\\machinename\sharename
So if your folder dir2 not shared, there is no way you could map it directly
-
Jan 6th, 2003, 01:08 PM
#8
Thread Starter
Fanatic Member
but i will say it again in win2000 it can be done why?
-
Jan 6th, 2003, 01:12 PM
#9
Addicted Member
In this instance I would say that Win 2000 is incorrect. You can only map to a Shared Resource, so Win 98 is not in error here (surprise!).
For example, if you want to map to Dir2, then Dir2 needs to be shared - a share within a share if you like.
So....
\\machinename\SharedDirectory1 = First available share
\\machinename\Dir1\SharedDirectory2 = Second available share
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
-
Jan 6th, 2003, 01:17 PM
#10
Thread Starter
Fanatic Member
what are u saying that is a win2000 bug?
-
Jan 6th, 2003, 01:26 PM
#11
Frenzied Member
I'm not a network person, but I think it has something to do with NTFS. Win 2000 build on NT technology which is more secure than win 98.
-
Jan 6th, 2003, 01:42 PM
#12
Thread Starter
Fanatic Member
yes my Os is Win2000 on a h/d that is NTFS but the directories that i m trying to connect are on a FAT32 h/d
-
Jan 6th, 2003, 01:56 PM
#13
Fanatic Member
You can't map to directories inside of a shared directory.
you'll have to share the other folder and map directly to it.
It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.
-
Jan 6th, 2003, 02:10 PM
#14
Addicted Member
Originally posted by Dalceon
You can't map to directories inside of a shared directory.
you'll have to share the other folder and map directly to it.
Correct.
If you want to map to both Dir1 and Dir2 then they both must be independantly Shared.
Dir1 = Share1
Dir2 = Share2
then:
Q: = \\machinename\Share1
R: = \\machinename\Share2
Some days you're the dog,
and some days you're the hydrant.
VB6 Enterprise
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|