1
CreateFileWを使用してファイルハンドルを取得できる場合でも、VBAからGetFileSecurityWを呼び出すと、常に「ファイルが見つかりません」が返されます。 UNCファイルパスからGetFileSecurityWは常にFileを返しません。
sUnicode = MakeUnicode(szfilename)
Debug.Print sUnicode
bSuccess = GetFileSecurityW(StrPtr(MakeUnicode(szfilename)), OWNER_SECURITY_INFORMATION, 0, 0&, _
sizeSD)
Debug.Print ErrorMsg(Err.LastDllError)
Const GENERIC_READ As Long = &H80000000
Const OPEN_EXISTING = &H3
Const FILE_SHARE_READ = &H1
Const FILE_ATTRIBUTE_ARCHIVE As Long = &H20
Const FILE_ATTRIBUTE_HIDDEN As Long = &H2
Const FILE_ATTRIBUTE_READONLY As Long = &H1
Const FILE_ATTRIBUTE_SYSTEM As Long = &H4
Const FILE_ATTRIBUTE_NORMAL = &H80&
Dim Flags As Long, Access As Long
Dim Disposition As Long, Share As Long
Access = GENERIC_READ
Share = FILE_SHARE_READ
Disposition = OPEN_EXISTING
Flags = FILE_ATTRIBUTE_ARCHIVE Or FILE_ATTRIBUTE_HIDDEN Or FILE_ATTRIBUTE_NORMAL _
Or FILE_ATTRIBUTE_READONLY Or FILE_ATTRIBUTE_SYSTEM
Debug.Print CreateFileW(StrPtr(sUnicode), Access, Share, ByVal 0&, Disposition, Flags, 0&)
デバッグ出力、以下の実施例
\\?\UNC\kazw029530\Test Long File Folder Name\DAFF004 - ICON\201104 DAFF004 ICON SR3 LOMP3P WBS FGOV-5100035-01-10 110506 LOMP003P RiskAnalysis vA1 4.xls
The system cannot find the file specified.
4448