C# 如何PInvoke SFileFindFirstFile
声明是C# 如何PInvoke SFileFindFirstFile,c#,pinvoke,C#,Pinvoke,声明是 typedef struct _SFILE_FIND_DATA { char cFileName[MAX_PATH]; // Full name of the found file char * szPlainName; // Plain name of the found file DWORD dwHashIndex; // Hash table index for the f
typedef struct _SFILE_FIND_DATA
{
char cFileName[MAX_PATH]; // Full name of the found file
char * szPlainName; // Plain name of the found file
DWORD dwHashIndex; // Hash table index for the file
DWORD dwBlockIndex; // Block table index for the file
DWORD dwFileSize; // File size in bytes
DWORD dwFileFlags; // MPQ file flags
DWORD dwCompSize; // Compressed file size
DWORD dwFileTimeLo; // Low 32-bits of the file time (0 if not present)
DWORD dwFileTimeHi; // High 32-bits of the file time (0 if not present)
DWORD lcLocale; // Locale version
} SFILE_FIND_DATA, *PSFILE_FIND_DATA;
HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DATA * lpFindFileData, const char * szListFile)</pre>
是这样吗?它不会出错,但不会返回它应该返回的内容。
szplanname
不应该是字节[]
-运行时如何知道数组有多大?试试这个:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public unsafe struct SFILE_FIND_DATA
{
fixed byte cFileName[260]; // Full name of the found file
string szPlainName; // Plain name of the found file
uint dwHashIndex; // Hash table index for the file
uint dwBlockIndex; // Block table index for the file
uint dwFileSize; // File size in bytes
uint dwFileFlags; // MPQ file flags
uint dwCompSize; // Compressed file size
uint dwFileTimeLo; // Low 32-bits of the file time (0 if not present)
uint dwFileTimeHi; // High 32-bits of the file time (0 if not present)
uint lcLocale; // Locale version
}
它返回什么?您希望它返回什么?如果您将
byte[]szPlainName
更改为IntPtr szPlainName
,它是否有效?您是否尝试过它,或者您只是在猜测?如果我没有函数的代码,我如何尝试?什么,错了吗?
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public unsafe struct SFILE_FIND_DATA
{
fixed byte cFileName[260]; // Full name of the found file
string szPlainName; // Plain name of the found file
uint dwHashIndex; // Hash table index for the file
uint dwBlockIndex; // Block table index for the file
uint dwFileSize; // File size in bytes
uint dwFileFlags; // MPQ file flags
uint dwCompSize; // Compressed file size
uint dwFileTimeLo; // Low 32-bits of the file time (0 if not present)
uint dwFileTimeHi; // High 32-bits of the file time (0 if not present)
uint lcLocale; // Locale version
}