I have found this function GetFileSizeEx(), which returns the size of file in PLARGE_INTEGER that is formed by the union of structures.
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
} ;
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
Is it same as if I'd call it structure of structu开发者_运维百科res? How can I figure the file size that it has returned and how large information can it handle?
You are probably misunderstanding what a union
is. A file's length is obtained by
LARGE_INTEGER len_li;
GetFileSizeEx (hFile, &len_li);
int64 len = (len_li.u.HighPart << 32) | len_li.u.LowPart;
Alternatively, you can access the 64 bit representation directly with modern compilers:
LARGE_INTEGER len_li;
GetFileSizeEx (hFile, &len_li);
LONGLONG len_ll = len_li.QuadPart;
no a union is NOT a struct of structs.
I suggest you read this question and answers: Difference between a Structure and a Union in C
hope this helps to clarify :)
精彩评论