This Code checks to see if a system file is protected on a Windows 2000 system.
Declare Function SfcIsFileProtected Lib "sfc.dll" (ByVal handle As Long, ByVal ProtFileName As String) As Boolean Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Public Const MAX_PATH As Integer = 260 Public Function bIsSystemFileProtected(sFileName As String) As Boolean 'Windows 2000 - Win 98 b? Requires sfc.dll Dim szPath As String Dim szFileName As String Dim szWideFileName As String szPath = SysDir() If Len(sFileName) > Len(szPath) Then If Left(UCase(sFileName), Len(szPath)) = UCase(szPath) Then szFileName = sFileName Else szFileName = szPath & sFileName End If Else szFileName = szPath & sFileName End If szWideFileName = Space(MAX_PATH) szWideFileName = StrConv(szFileName, vbUnicode) bIsSystemFileProtected = SfcIsFileProtected(0, szWideFileName) End Function Function SysDir() As String Dim sysBuf As String Dim nulPos As Integer sysBuf = Space(MAX_PATH) If GetSystemDirectory(strBuf, 80) = 0 Then strBuf = "" nulPos = InStr(strBuf, Chr(0)) If nulPos > 0 Then strBuf = Left(strBuf, nulPos - 1) SysDir = strBuf End Function