Make your own free website on

Getting all network drives

Back Up Next

Author: Eric Aling

This is a little routine to get all the network drives, that is, letters mapped to network drivers. What we do is we walk through the alphabet, looking op every letter that is mapped to a network drive. This can be done by using the Windows API function WNETGetConnection(). It now starts with letter 'A', but you can modify that to let it start by i.e. the 'F'.

For 16bit, use the following external function:

FUNCTION UINT WNetGetConnection( ref string ln, ref string rn, ref uint cb ) library "user.exe"

For 32bit, use this one:

FUNCTION UINT WNetGetConnectionA( ref string ln, ref string rn, ref uint cb ) library "mpr.dll"

Use the following script in a listbox userobject, for instance in the constructor event. The instance variable ii_bShowNotConnected lets you also display not connected drive letters. Default, set it to FALSE.

string	ls_LocalName
string 	ls_RemoteName
int 		i_iX
uint 		ui_cb

FOR iX = 1 to 26
	ls_LocalName = char ( 64 + iX ) + ":"
	l_sRemoteName = space(128)
	ui_cb = 127
	IF WNetGetConnectionA( ls_LocalName, ls_RemoteName, ui_cb ) = 0 THEN
		This.AddItem ( ls_LocalName + "~t- " + ls_RemoteName )
		IF ii_bShowNotConnected THEN
			This.AddItem ( ls_LocalName + "~t- not connected" )

Back Up Next