Trainee
Date of registration: Mar 16th 2009
Location: Perth, WA, Australia
Occupation: Software/Test Engineer
Hobbies: be a husband and a dad, play ukulele, sing
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
Option Explicit Private WinAPI Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesW" ( _ ByVal lpFileName As Long) As Long Private fDir As java#io#File Private iDirIndex As Integer Private aDirFiles() As java#io#File Public Function Dir() As String Dim i As Long Dim s As String Dim a As Long If iDirIndex <= Ubound(aDirFiles) Then s = aDirFiles(iDirIndex).getPath.toString 'getName i = varptr.CreateVar("foo","String",Len(s)) a = GetFileAttributes(i) Debug.Print a Dir = s iDirIndex = iDirIndex + 1 varptr.DestroyVar("foo") Else iDirIndex = 0 Dir = vbNullString End If End Function Public Function Dir(sPathName As String) As String fDir = New java#io#File(sPathName) Dir = fDir.getPath Dim i As Long Dim attr As Long i = varptr.CreateVar( "foo","String",Len(sPathName)) Debug.Print i varptr.SetStringVar("foo",sPathName) attr = GetFileAttributes(i) Debug.Print attr aDirFiles = fDir.listFiles Dir = aDirFiles(0).getPath.toString iDirIndex = iDirIndex + 1 varptr.DestroyVar("foo") End Function |
Quoted
Problem now is working out how to pass a pointer to a string to a *W function.
Quoted
Please tell me there's another way of getting at the Win32 file attributes (particularly the archive bit).
MySQL queries |
|
1 2 3 |
Library Scripting C:\WINDOWS\system32\scrrun.dll Microsoft Scripting Runtime |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Option Explicit Dim myBase As Dispatch Public Sub FileSystemObject() myBase = New ActiveXComponent("Scripting.FileSystemObject").getObject() End Sub Public Property Get FileAttributes(path As String) As VBA#VbFileAttribute Dim aFile As Dispatch = Dispatch.call(myBase, "GetFile", path).getDispatch FileAttributes = New VBA#VbFileAttribute(Dispatch.call(aFile, "Attributes").getInt) End Property |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 |
Option Explicit Dim myFileSO As New FileSystemObject Public Sub Command1_Click() Dim a As VBA#VbFileAttribute = myFileSO.FileAttributes("C:\Test.txt") MsgBox a.getName & ": " & CStr(a.intValue) End Sub |
Trainee
Date of registration: Mar 16th 2009
Location: Perth, WA, Australia
Occupation: Software/Test Engineer
Hobbies: be a husband and a dad, play ukulele, sing
Marvellous idea! Wonderful! When?in the next version of the Jabaco framework the getName-function of an enum-value will also deliver all names as flags set in a flag-enum. (so is the VBFileAttributes-enum)
*cringe* wo gehobelt wird da fallen Späne -> it's under constructionQuoted
sad to say, isn't in my copy
Quoted
Is there a better one
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Enum FileAttributes ' Fields ReadOnly = &H1 Hidden = &H2 System = &H4 '? Directory = &H10 Archive = &H20 Device = &H40 Normal = &H80 Temporary = &H100 SparseFile = &H200 ReparsePoint = &H400 Compressed = &H800 Offline = &H1000 NotContentIndexed = &H2000 Encrypted = &H4000 End Enum Enum VbFileAttribute vbNormal = &H0 vbReadOnly = &H1 vbHidden = &H2 vbSystem = &H4 vbVolume = &H8 vbDirectory = &H10 vbArchive = &H20 vbAlias = &H40 End Enum |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves