The Win32 console application is created in the compiling environment of VC ++ 6.0.
# Include <stdafx. h>
# Include <string. h>
# Include <windows. h>
DWORD showfiletime (pfiletime lptime)
{
// File Time Structure
Filetime ftlocal;
// System Time Structure
Systemtime st;
// Adjust the time to the system's Time Zone
Filetimetolocalfiletime (lptime, & ftlocal );
// Convert the file time to the systemtime format for easy display
Filetimetosystemtime (& ftlocal, & St );
// Display the time string
Printf ("% 4D year % # 02d month % # 02d day, % # 02d: % # 02d: % # 02d \ n", St. wyear, St. wmonth, St. wday, St. whour, St. wminute, St. wsecond );
Return 0;
}
DWORD showfilesize (DWORD dwfilesizehigh, DWORD dwfilesizelow)
{
Ulonglong lifilesize;
Lifilesize = dwfilesizehigh;
// Move to 32 bits
Lifilesize <= sizeof (DWORD) * 8;
Lifilesize + = dwfilesizelow;
Printf ("W file size: \ t % i64u byte \ n", lifilesize );
Return 0;
}
DWORD showfileattrinfo (DWORD dwattribute)
{
// Judge and display attributes in sequence
Printf ("file attributes: \ t ");
If (dwattribute & file_attribute_archive)
Printf ("<archive> ");
If (dwattribute & file_attribute_compressed)
Printf ("<compression> ");
If (dwattribute & file_attribute_directory)
Printf ("<directory> ");
If (dwattribute & file_attribute_encrypted)
Printf ("<encryption> ");
If (dwattribute & file_attribute_hidden)
Printf ("If (dwattribute & file_attribute_normal)
Printf ("<normal> ");
If (dwattribute & file_attribute_offline)
Printf ("<offline> ");
If (dwattribute & file_attribute_readonly)
Printf ("<read-only> ");
If (dwattribute & file_attribute_sparse_file)
Printf ("<sparse> ");
If (dwattribute & file_attribute_system)
Printf ("<System File> ");
If (dwattribute & file_attribute_temporary)
Printf ("<Temporary File> ");
Printf ("\ n ");
Return 0;
}
DWORD showfileattributes (lpstr szpath)
{
// File Attribute Structure
Win32_file_attribute_data wfad;
Printf ("file: % s \ n", szpath );
// Get file attributes
If (! Getfileattributesex (szpath, getfileexinfostandard, & wfad ))
{
Printf ("File Attribute retrieval error: % d \ n", getlasterror ());
Return 1;
}
// Display the related time
Printf ("Creation Time: \ t ");
Showfiletime (& (wfad. ftcreationtime ));
Printf ("last access time: \ t ");
Showfiletime (& (wfad. ftlastaccesstime ));
Printf ("last modification time: \ t ");
Showfiletime (& (wfad. ftlastwritetime ));
// Display the file size
Showfilesize (wfad. nfilesizehigh, wfad. nfilesizelow );
// Display file attributes
Showfileattrinfo (wfad. dwfileattributes );
Return 0;
}
Int main (pchar argv [])
{
Printf ("Enter the file path \ n ");
Scanf ("% s", argv );
Showfileattributes (argv [0]);
Printf ("display Parameters specify the attributes, time, and size of the file; \ n ");
Return 0;
}
This Program After running the program, a line of "Enter file path" is displayed, and the program crashes after you press enter in a path ............