473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Create Folder Share on Remote Computer

I have an application where I am providing the user the ability to
select or create a folder on a domain, using SHBrowseForFolder. When
the user selects/creates a folder on a remote computer, it returns the
UNC path of that folder.

Using ADSI IADsFileShare, I would like to create that share, but the
..Path property seems to reject the UNC. Is there a way of converting
that UNC to the logical drive path or some other way of setting the
path in order to Set the Share?

Much Thanks.
Jul 17 '05 #1
4 17846
Something to check out is the NetShareGetInfo API: - No environment where I
currently am to test, but check it out seems promising...

NetShareGetInfo with Sample
http://www.mentalis.org/apilist/NetShareGetInfo.shtml

NetShareGetInfo on MSDN
http://msdn.microsoft.com/library/de...aregetinfo.asp

<---Going the other way--->

HOWTO: Get UNC Path From a Mapped Network Share's Drive Letter
http://support.microsoft.com/default...NoWebContent=1

ACC: How to Return an UNC Path from an Existing Drive Letter
http://support.microsoft.com/default...NoWebContent=1

--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
--

"Dave" <dm*****@yahoo.com> wrote in message
news:6c**************************@posting.google.c om...
I have an application where I am providing the user the ability to
select or create a folder on a domain, using SHBrowseForFolder. When
the user selects/creates a folder on a remote computer, it returns the
UNC path of that folder.

Using ADSI IADsFileShare, I would like to create that share, but the
.Path property seems to reject the UNC. Is there a way of converting
that UNC to the logical drive path or some other way of setting the
path in order to Set the Share?

Much Thanks.

Jul 17 '05 #2

"Dave" <dm*****@yahoo.com> wrote in message
news:6c**************************@posting.google.c om...
I have an application where I am providing the user the ability to
select or create a folder on a domain, using SHBrowseForFolder. When
the user selects/creates a folder on a remote computer, it returns the
UNC path of that folder.

Using ADSI IADsFileShare, I would like to create that share, but the
.Path property seems to reject the UNC. Is there a way of converting
that UNC to the logical drive path or some other way of setting the
path in order to Set the Share?


Creating a folder and creating a share are two different things. What
exactly are you trying to do?
Jul 17 '05 #3
As Jeff said, creating folders and sharing are different beasts. The code to
actually create a share on a local or remote machine can be found at
http://vbnet.mvps.org/code/network/netshareadd.htm

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Dave" <dm*****@yahoo.com> wrote in message
news:6c**************************@posting.google.c om...
: I have an application where I am providing the user the ability to
: select or create a folder on a domain, using SHBrowseForFolder. When
: the user selects/creates a folder on a remote computer, it returns the
: UNC path of that folder.
:
: Using ADSI IADsFileShare, I would like to create that share, but the
: .Path property seems to reject the UNC. Is there a way of converting
: that UNC to the logical drive path or some other way of setting the
: path in order to Set the Share?
:
: Much Thanks.

Jul 17 '05 #4
"Dave" <dm*****@yahoo.com> wrote in message
news:6c**************************@posting.google.c om...
I have an application where I am providing the user the ability to
select or create a folder on a domain, using SHBrowseForFolder. When
the user selects/creates a folder on a remote computer, it returns the
UNC path of that folder.

Using ADSI IADsFileShare, I would like to create that share, but the
.Path property seems to reject the UNC. Is there a way of converting
that UNC to the logical drive path or some other way of setting the
path in order to Set the Share?

Much Thanks.


Just pass the UNC path to the GetLocalPath function (below) and it will
return the server local path.

'----------
Private Type MungeLong
x As Long
Dummy As Integer
End Type

Private Type MungeInt
XLo As Integer
XHi As Integer
Dummy As Integer
End Type

Private Declare Function NetShareGetInfo Lib "NETAPI32" _
(ByRef ServerName As Byte, _
ByRef NetName As Byte, _
ByVal Level As Long, _
ByRef buffer As Long) As Long

Private Declare Function NetAPIBufferFree Lib "netapi32.dll" _
Alias "NetApiBufferFree" (bufptr As Any) As Long

Private Declare Function PtrToInt Lib "kernel32" Alias "lstrcpynW" _
(RetVal As Any, ByVal Ptr As Long, _
ByVal nCharCount As Long) As Long

Private Declare Function PtrToStr Lib "kernel32" Alias "lstrcpyW" _
(RetVal As Byte, ByVal Ptr As Long) As Long

Private Declare Function StrLen Lib "kernel32" Alias "lstrlenW" _
(ByVal Ptr As Long) As Long

Public Function GetLocalPath(sUNCPath As String) As String
Dim sTemp As String
Dim sServer As String
Dim sShare As String
Dim baServer() As Byte
Dim baShare() As Byte
Dim Result As Long
Dim Buf As Long
Dim TempStr As MungeInt
Dim TempPtr As MungeLong
Dim STRArray(0 To 255) As Byte
Dim sBasePath As String

sTemp = Mid(sUNCPath, 3)
sServer = Left(sTemp, InStr(1, sTemp, "\") - 1)
sTemp = Mid(sTemp, InStr(1, sTemp, "\") + 1)
If InStr(1, sTemp, "\") > 0 Then
sShare = Left(sTemp, InStr(1, sTemp, "\") - 1)
sTemp = Mid(sTemp, InStr(1, sTemp, "\"))
Else
sShare = sTemp
sTemp = ""
End If

baServer = "\\" & sServer & Chr(0)
baShare = UCase(sShare) & Chr(0)

Result = NetShareGetInfo(baServer(0), baShare(0), 2, Buf)
mvarLastError = Result

If Result = 0 Then
Result = PtrToInt(TempStr.XLo, Buf + 24, 2)
Result = PtrToInt(TempStr.XHi, Buf + 26, 2)
LSet TempPtr = TempStr
Result = PtrToStr(STRArray(0), TempPtr.x)
sBasePath = Left(STRArray, StrLen(TempPtr.x))

Result = NetAPIBufferFree(Buf)

Server = sServer
GetLocalPath = sBasePath & sTemp
End If
End Function

'----------

--
Björn Holmgren
Guide Konsult AB
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sajithm | last post by:
Hi all, I have a problem while trying to create folder and files in a remot storage server using asp.net. Actually I was trying with filesystem object and this says bad usernam and passeord,....
2
by: freenews.netfront.net | last post by:
Hi, I am writing an asp.net / Active Directory application using vb.net in it's code-behind pages. The app is running on the W2k3 (r1) domain controller (e.g. server1). Does anyone know how...
2
by: Joey | last post by:
Hey, I need to create a share on a remote folder using VB.NET, On the remote server, there is NO WMI, hence I need to find a way to do so, Without using WMI. Thanks ahead, --Joey
2
by: schaf | last post by:
Hi Ng ! I'm a little confused because of my application. I need to access a file in the path C:\Temp\test.txt on a computer in the same network. Now I just know the IP address of this PC. Is it...
3
by: Brian Hampson | last post by:
I've swiped the following code pretty much directly from a technet article, and modified it for my purposes. Something isn't working. I'm trying to 1) create a share on a remote server...
3
by: joja15 | last post by:
I am working on a Python script to perform as a remote computer manager. So far I have a WOL function working and I would like to add the ability to show if a machine is on or off (I figured I...
1
by: jarremw | last post by:
hello all, how would i go about creating a folder on a remote machine? and also how would i move files to that location also? is it that much different than doing it on a local machine? thanks in...
3
by: =?Utf-8?B?T21hcg==?= | last post by:
Hi, i want to create a folder in remote computer in c# without using WMI. any help? thanks.
2
by: Tony WONG | last post by:
there is an asp page at IIS server for creating folder at remote site via virtual folder it is tested at Windows 2003 server. the asp is ok if http://localhost/test.asp however it is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.