Connecting to network share using UNC file path?

Windows specific forum
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Connecting to network share using UNC file path?

Post 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!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Hi-Toro
Enthusiast
Enthusiast
Posts: 270
Joined: Sat Apr 26, 2003 3:23 pm

Post 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

James Boyd
http://www.hi-toro.com/
Death to the Pixies!
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post 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
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

Hi-Toro,

exactly what the doctor ordered! Works like a charm. Thanks a lot for posting your solution.
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Post Reply