Re: SfcGetNextProtectedFile(...) returns ERROR_IO_PENDING (997).
Hi Tom,
this is the right Signature to C# PInvoke for the
Function, i just forget to set last error (SetLastError=True)
in the declaration:
public const int ERROR_NO_MORE_FILES = 0x12;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PROTECTED_FILE_DATA
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string FileName;
public Int32 FileNumber;
}
[DllImport("sfc.dll", CharSet = CharSet.Unicode, SetLastError =
true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SfcGetNextProtectedFile([In]IntPtr
RpcHandle,
[In][Out] ref PROTECTED_FILE_DATA ProtFileData);
This one works just fine. And if you could tell me how i can make this
work on Windows Vista and Windows Seven, since the SfcGetNextProtectedFile
wont work anymore on the operating system versions,...:-( I need to get the
full list
of all system protected files, not only with one file as it can be done with
the function
SfcIsFileProtected(....), i need the full list of all files!
Regards
Kerem
--
--
-----------------------
Beste Gr?sse / Best regards / Votre bien devoue
Kerem G?mr?kc?
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Tom Serface" <tom@nospam.camaswood.com> schrieb im Newsbeitrag
news:46F7FD95-9D78-4849-A143-9FEB575C7204@microsoft.com...
The process is correct, but the code is wrong. I'd just do something
like:
PROTECTED_FILE_DATA myData;
myData.FileNumber=0;
while(SfcGetNextProtectFile(NULL, &myData))
{
// Do whatever with results
}
This article may be of interest to you:
http://www.codeguru.com/cpp/w-p/files/fileinformation/article.php/c8955
Tom
"Kerem G?mr?kc?" <kareem114@hotmail.com> wrote in message
news:ekC3Ea7pJHA.6096@TK2MSFTNGP02.phx.gbl...
Hi,
i run SfcGetNextProtectedFile(....) this way until it
returns false (its C# code but same as C)
while ( returns (IntPtr.Zero, ref pfd) != false)
{
ProtectedFiles.Add(pfd.FileName);
}
end when it ends i check the result with Marshal.GetLastWin32Error()
what the last error is, but it is not ERROR_NO_MORE_FILES (18), it is a
ERROR_IO_PENDING (997). The proc returns no more files and FALSE
when its done with the list, but here the result after FALSE is 997. I
print
the result of pdf.FileName to debug output with OutputdebugString and
i could see that it prints many filenames until it goes FALSE and 997.
But
why 997? The same for 2000 and XP, but why? Did i miss something here?
The code runs Windows 2000 and XP only, Vista and Upper do not
support this function anymore....
Regards
Kerem
--
--
-----------------------
Beste Gr?sse / Best regards / Votre bien devoue
Kerem G?mr?kc?
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."