Enum Named PipesAuthor: Dave Date: 03.23.16 - 4:49am So I dont loose this little clip. I think there is a way to enum anonymous pipes too but I forget. Private Sub Form_Load() Dim tmp() As String tmp() = GetFolderFiles("\\.\pipe\") Debug.Print Join(tmp, vbCrLf) End Sub Function GetFolderFiles(folder As String, Optional filter = ".*", Optional retFullPath As Boolean = True) As String() Dim fnames() As String If Not FolderExists(folder) Then 'returns empty array if fails GetFolderFiles = fnames() Exit Function End If folder = IIf(Right(folder, 1) = "\", folder, folder & "\") If Left(filter, 1) = "*" Then extension = Mid(filter, 2, Len(filter)) If Left(filter, 1) <> "." Then filter = "." & filter fs = Dir(folder & "*" & filter, vbHidden Or vbNormal Or vbReadOnly Or vbSystem) While fs <> "" If fs <> "" Then push fnames(), IIf(retFullPath = True, folder & fs, fs) fs = Dir() Wend GetFolderFiles = fnames() End Function Sub push(ary, value) 'this modifies parent ary object On Error GoTo init X = UBound(ary) '<-throws Error If Not initalized ReDim Preserve ary(UBound(ary) + 1) ary(UBound(ary)) = value Exit Sub init: ReDim ary(0): ary(0) = value End Sub Function FolderExists(path As String) As Boolean On Error GoTo hell Dim tmp As String tmp = path & "\" If Len(tmp) = 1 Then Exit Function If Dir(tmp, vbDirectory) <> "" Then FolderExists = True Exit Function hell: FolderExists = False End Function Comments: (0) |
About Me More Blogs Main Site
|
||||||||||||||||||||||||||||||||||||||