Hello,
How can I read a full pathname of a network connection?
Example : the drive letter is F:. How do can I get the fulle pathname of the network connection ? (ex. \\COMPUTER1\MAP1\MAP2)
Thanks a lot in advance for any help.
Sub abc()
Dim fs As Object
Set fs = CreateObject("Scripting.fileSystemObject")
For Each dr In fs.Drives
msgbox dr.DriveLetter & " - " & dr.ShareName
Next
End Sub
function GetDriveLetter( cPath )
local o := CreateObject( "Scripting.fileSystemObject" )
return o:GetDrive( o:GetDriveName( o:GetAbsolutePathName( cPath ) ) )
function GetAName( cDriveSpec )
local o := CreateObject( "Scripting.fileSystemObject" )
return o:GetDriveName( cDriveSpec )
MsgInfo( GetAName( "O" ) )
MsgInfo( GetDriveLetter( "\\COMPUTER3\C\SOFTWARE\JUDA\DATA" ) )
function UNCNAME( cPath )
local cDrive, cMap
cPath := TrueName( cPath )
if SubStr( cPath, 2, 1 ) == ":"
cDrive := Left( cPath, 2 )
if Empty( cMap := DRIVEMAP( cDrive ) )
if File( cPath ) .or. IsDir( cPath )
cPath := "\\" + NetName() + "\" + cPath
cPath := StrTran( cPath, ":", "\" )
endif
else
cPath := cMap + SubStr( cPath, 3 )
endif
endif
return cPath
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC( DRIVEMAP )
{
LPCSTR drive = hb_parc( 1 );
char path[ 80 ];
DWORD len = 80;
if ( WNetGetConnection( drive, path, &len ) == 0 ) { hb_retc( path ); }
else { hb_retc( "" ); }
}
#pragma ENDDUMP
? UNCNAME( <your_file_or_folder_name> )
Antonio Linares wrote:Dear Michael,
You may use WNetGetUniversalName()
HB_FUNC( UNC_NAME )
{
DWORD cbBuff = 1000;
TCHAR szBuff[1000];
UNIVERSAL_NAME_INFO * puni = (UNIVERSAL_NAME_INFO *) &szBuff;
DWORD dwRes;
LPCSTR strPath = hb_parc( 1 );
dwRes = WNetGetUniversalName( strPath, UNIVERSAL_NAME_INFO_LEVEL, puni, &cbBuff );
if ( dwRes == NO_ERROR ) { hb_retc( puni->lpUniversalName ); }
else { hb_retc( strPath ); }
}
? UNC_NAME( <file_folder_name> )
// where .exe started from is default directory //
cFILE := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,nSTART-1)
msginfo( cDefa )
? cFilePath( hb_argv( 0 ) )
Rick Lipkin wrote:This code has served me well over the years ..
- Code: Select all Expand view RUN
// where .exe started from is default directory //
cFILE := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,nSTART-1)
msginfo( cDefa )
Rick Lipkin
cFilePath( hb_argv( 0 ) ) // Christobal
// OR
cFilePath( ExeName() )
? UNCNAME( "L:\FWH\whatsnew.txt" ) // --> "\\GNRDELL\C\FWH\whatsnew.txt"
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 70 guests