Page 1 of 1

Connecting to network share using UNC file path?

Posted: Wed Feb 11, 2004 12:19 am
by dell_jockey
Hi Group,

after searching this forum to no avail, I'd like to ask you how I connect to a network share (local, LAN & WAN) using UNC paths _within_ a PB application?

examples of paths I'd like to connect to:

\\localhost\admin$
\\server\shared-apps

etc., you get the idea! It's not solely about opening a file that may exist on such a share; another usage would be to check whether a share exists at all.

thanks for any help!

Posted: Fri Feb 27, 2004 8:20 pm
by Hi-Toro
I'm not sure if this is what you mean, but I found this stuff on MSDN:

http://msdn.microsoft.com/library/defau ... ctions.asp

... and it's pretty cool anyway!

Connecting a remote path as a local 'drive' (appears in My Computer)...

Code: Select all


; CHANGE THESE PATHS TO SUIT!

remote$ = "\\Vampwillow\Downloads"      ; Remote path
local$ = "Z:"                                       ; Local drive to be 'created'

DefType.NETRESOURCE res

res\dwType = #RESOURCETYPE_DISK
res\lpLocalName = @local$
res\lpRemoteName = @remote$
res\lpProvider = #NULL

If WNetAddConnection2_ (res, #NULL, #NULL, 0) = #NO_ERROR

    MessageRequester ("Cool!", "Connected -- check My Computer!", #MB_ICONINFORMATION)

    WNetCancelConnection2_ (local$, #CONNECT_UPDATE_PROFILE, 0)

Else

    MessageRequester ("Cool!", "Couldn't connect -- check paths and network!", #MB_ICONWARNING)

EndIf
Using a browser window to create a 'drive' assigned to the remote path...

Code: Select all

; Assign remote path to drive (eg. "Z:")...

If WNetConnectionDialog_ (0, #RESOURCETYPE_DISK) = #NO_ERROR

    ; Have a look... go on...
    
    MessageRequester ("Cool!", "Look for the drive in My Computer now!", #MB_ICONINFORMATION)
    
    ; Remove assigned drive...
    
    WNetDisconnectDialog_ (0, #RESOURCETYPE_DISK)

Else

    MessageRequester ("Cool!", "Couldn't connect -- check paths and network!", #MB_ICONWARNING)

EndIf


Posted: Fri Feb 27, 2004 11:03 pm
by TerryHough
@Hi-Toro

Got to say Thanks!

Your code and the reference cause my tired brain to reconnect a synapse and a bit of coding later I have something working that I had failed with about 6 months ago.

See, you never know how much a tidbit can help someone else.

Thanks again,

Terry

Posted: Tue Mar 02, 2004 10:37 pm
by dell_jockey
Hi-Toro,

exactly what the doctor ordered! Works like a charm. Thanks a lot for posting your solution.