This code:
[DllImport("shell32", CharSet=CharSet.Unicode)]
private static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, out SHFILEINFO psfi, uint cbFileInfo, uint flags);
Causes the following Code Analysis problem:
CA1901 P/Invoke declarations should be portable
As it is declared in your code, the return type of P/Invoke 'IconUtil.SHGetFileInfo(string, uint, out IconUtil.SHFILEINFO, uint, uint)' will be 4 bytes wide on 64-bit platforms. This is not correct, as the actual native declaration of this API indicates it should be 8 bytes wide on 64-bit platforms. Consult the MSDN Platform SDK documentation for help determining what data type should be used instead of 'int'.
What am I supposed to do? I tried "consulting MSDN", but I'm not really sure what the problem even means.
I also get this for the same line:
CA1060 Move P/Invokes to NativeMethods class
Because it is a P/Invoke method, 'IconUtil.SHGetFileInfo(string, uint, out IconUtil.SHFILEINFO, uint, uint)' should be defined in a class named NativeMethods, SafeNativeMethods, or UnsafeNativeMethods.
SHGetFileInfoas returningint. DoesSHGetFileInforeturnint? According to MSDN, it does not. On x86, it's close enough. On x64, it isn't. That's what the first message is about. - user743382IconUtil, but it should be placed in a class namedNativeMethods,SafeNativeMethods, orUnsafeNativeMethods. Check MSDN to find out which of the three you should use. - dtb