Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 376
Joined: 14 Nov 2002 0:01

Listing network places

Post by Martin Meyer »

Hello Thomas,

the file explorer on my (german) PC displays a lot of stuff:

explorer.jpg

I enumerate the local drives (in green frame) by this code:

Code: Select all

    open core   constants     volumeBufferLength : charCount = 1024.     volumeBufferSize : byteCount = volumeBufferLength * sizeOfDomain(char).   class predicates     getVolumePathName_nd : (string VolumeName [out]) -> string VolumePathName nondeterm. clauses     getVolumePathName_nd(VolumeName) = VolumePathName :-         VolumeName = getVolumeName_nd(),         VolumePathName = getVolumePathNameForVolumeName_nd(VolumeName).   class predicates     getVolumeName_nd : () -> string VolumeName nondeterm.   class predicates     getVolumePathNameForVolumeName_nd : (string VolumeName) -> string VolumePathName nondeterm. clauses     getVolumeName_nd() = VolumeName :-         VolumeNameBuffer = memory::allocString(volumeBufferLength, memory::contextType_fileSystem),         FindHandle = fileSystem_native::findFirstVolume(VolumeNameBuffer, volumeBufferSize),         FindHandle <> invalidHandle,         try             VolumeNameList =                 [ VolName ||                     VolName = string::createBufferCopy(VolumeNameBuffer, volumeBufferLength)                     or                     std::repeat(),                     if fileSystem_native::findNextVolume(FindHandle, VolumeNameBuffer, volumeBufferSize) = b_true then                         VolName = string::createBufferCopy(VolumeNameBuffer, volumeBufferLength)                     else                         !,                         fail                     end if                 ]         finally             _CloseSuccess = fileSystem_native::findVolumeClose(FindHandle)         end try,         VolumeName in VolumeNameList.   clauses     getVolumePathNameForVolumeName_nd(VolumeName) = VolumePathName :-         DriveMemArray = memory::allocString(volumeBufferLength, memory::contextType_fileSystem),         ReturnLength = memory::alloc_atomic(memory::contextType_fileSystem),         fileSystem_native::getVolumePathNamesForVolumeName(VolumeName, DriveMemArray, volumeBufferSize, ReturnLength) = b_true,         VolumePathNames = memArrayToDriveList(DriveMemArray),         VolumePathName in VolumePathNames.   class predicates     memArrayToDriveList : (string DriveRootPath) -> string* DriveRootPathList. clauses     memArrayToDriveList(DriveRootPath) = DriveRootPathList :-         if DriveRootPath = "" then             DriveRootPathList = []         else             DupDriveRootPath = string::createBufferCopy(DriveRootPath, volumeBufferLength),             DriveRootPathInclEndLen = string::length(DriveRootPath) + 1,             NextDriveRootPathPointer = memory::pointerAdd(uncheckedConvert(pointer, DriveRootPath), DriveRootPathInclEndLen * sizeOfDomain(char)),             DriveRootPathList = [DupDriveRootPath | memArrayToDriveList(uncheckedConvert(string, NextDriveRootPathPointer))]         end if.   clauses     run() :-         foreach VolumePathName = getVolumePathName_nd(_VolumeName) do             stdIO::write(VolumePathName, '\n')         end foreach.
It outputs on my PC:

C:\
D:\
Z:\


Is there a way to also list the devices on the local network (orange frame) as well as my shared network folders (blue frame)?
You do not have the required permissions to view the files attached to this post.
Regards Martin