用到那个WindowsAPI或者ShellAPI?
解决方案 »
- 一段程序在XP professional和 home下的不同结果
- com输出参数
- 问有关ADO连接数据源的几行程序
- 如何用HOOK,鉤取某個窗口上(Windows Media Player)的按鈕消息????
- 【用Soap tool kit怎么返回字节数组?】
- 请教:定义的这个宏实现了什么功能?谢谢!
- [hoho]错扣信誉分已经全部恢复
- 求教:如何强行关闭正在被其它程序占用的串行端口??
- vc在Release方式下如何在工程里设置,使得编程照样能调试?
- GetActiveView()->SetDlgItemText(IDC_EDIT_TELENUM_1,"12345678")
- 有没有象SetCapture捕捉鼠标一样类型的捕捉键盘的函数。
- 高分求Hart协议编程实例
* report information about the file named STAT.C.
*/#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>void main( void )
{
struct _stat buf;
int result;
char buffer[] = "A line to output"; /* Get data associated with "stat.c": */
result = _stat( "stat.c", &buf ); /* Check if statistics are valid: */
if( result != 0 )
perror( "Problem getting information" );
else
{
/* Output some of the statistics: */
printf( "File size : %ld\n", buf.st_size );
printf( "Drive : %c:\n", buf.st_dev + 'A' );
printf( "Time modified : %s", ctime( &buf.st_atime ) );
}
}
OutputFile size : 745
Drive : C:
Time modified : Tue May 03 00:00:00 1994
Example
/* stat.c: This program uses the _stat64 function to
* report information about the file named stat.c.
*/#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>void main( void )
{
struct __stat64 buf;
int result;
char buffer[] = "A line to output"; /* Get data associated with "stat.c": */
result = _stat64( "stat.c", &buf ); /* Check if statistics are valid: */
if( result != 0 )
perror( "Problem getting information" );
else
{
/* Output some of the statistics: */
printf( "File size : %ld\n", buf.st_size );
printf( "Drive : %c:\n", buf.st_dev + 'A' );
printf( "Time modified : %s", _ctime64( &buf.st_mtime ) );
}
}
Output
File size : 865
Drive : C:
Time modified : Fri Jan 22 07:44:56 1999
// time to a string
// Return value - TRUE if successful, FALSE otherwise
// hFile - must be a valid file handle
// lpszString - pointer to buffer to receive stringBOOL GetLastWriteTime(HANDLE hFile, LPSTR lpszString)
{
FILETIME ftCreate, ftAccess, ftWrite, ftLocal;
SYSTEMTIME stCreate; // Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
return FALSE; // Convert the last-write time to local time.
if (!FileTimeToLocalFileTime(&ftWrite, &ftLocal))
return FALSE; // Convert the local file time from UTC to system time.
FileTimeToSystemTime(&ftLocal, &stCreate); // Build a string showing the date and time.
wsprintf(lpszString, "%02d/%02d/%d %02d:%02d",
stCreate.wDay, stCreate.wMonth, stCreate.wYear,
stCreate.wHour, stCreate.wMinute); return TRUE;
}