merano
Mitglied
Benutzerprofil
Anmeldungsdatum: 21.12.2006
Beiträge: 231
|
merano Mitglied
00:17:56 03.12.2011 Titel: |
Re: Pipe schließen |
Zitieren |
| upstalsboom schrieb: | | Eigentlich war die Grundidee ein Programm was ähnlich unter Linux dem Befehl uptime ist. Also direkt die Zeit ausrechnet, an der man am Rechner sitzt. |
Warum machst Du das dann nicht ?
Google sagt:
http://www.codeguru.com/forum/archive/index.php/t-304599.html
Habs mit VS2010 kompiliert; scheint ganz gut zu funktionieren.
| C/C++ Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | typedef LONG (WINAPI *pNtQuerySystemInformation)(UINT,PVOID,ULONG,PULONG);
typedef struct _SYSTEM_TIME_OF_DAY_INFORMATION
{
LARGE_INTEGER BootTime;
LARGE_INTEGER CurrentTime;
LARGE_INTEGER TimeZoneBias;
ULONG CurrentTimeZoneId;
} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION;
BOOL GetUpTime(SYSTEMTIME *pstBootTime)
{
pNtQuerySystemInformation pfNtQuerySystemInformation;
SYSTEM_TIME_OF_DAY_INFORMATION SysTimeInfo;
FILETIME ftBootTime;
pfNtQuerySystemInformation = (pNtQuerySystemInformation)
GetProcAddress(GetModuleHandle(_T("ntdll")),"NtQuerySystemInformation");
if(!pfNtQuerySystemInformation)
return FALSE;
if(pfNtQuerySystemInformation(3,&SysTimeInfo,sizeof(SysTimeInfo),0) != NO_ERROR)
return FALSE;
ftBootTime = *(FILETIME *)&(SysTimeInfo.BootTime);
FileTimeToLocalFileTime(&ftBootTime,&ftBootTime);
FileTimeToSystemTime(&ftBootTime,pstBootTime);
return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD seconds;
SYSTEMTIME stBootTime;
if(GetUpTime(&stBootTime)) {
_tprintf(
_T("System Uptime: %d/%d/%d %d:%d:%d\n"),
stBootTime.wMonth,
stBootTime.wDay,
stBootTime.wYear,
stBootTime.wHour,
stBootTime.wMinute,
stBootTime.wSecond);
}
return 0;
}
| |
| C/C++ Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | typedef LONG (WINAPI *pNtQuerySystemInformation)(UINT,PVOID,ULONG,PULONG);
typedef struct _SYSTEM_TIME_OF_DAY_INFORMATION
{
LARGE_INTEGER BootTime;
LARGE_INTEGER CurrentTime;
LARGE_INTEGER TimeZoneBias;
ULONG CurrentTimeZoneId;
} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION;
BOOL GetUpTime(SYSTEMTIME *pstBootTime)
{
pNtQuerySystemInformation pfNtQuerySystemInformation;
SYSTEM_TIME_OF_DAY_INFORMATION SysTimeInfo;
FILETIME ftBootTime;
pfNtQuerySystemInformation = (pNtQuerySystemInformation)
GetProcAddress(GetModuleHandle(_T("ntdll")),"NtQuerySystemInformation");
if(!pfNtQuerySystemInformation)
return FALSE;
if(pfNtQuerySystemInformation(3,&SysTimeInfo,sizeof(SysTimeInfo),0) != NO_ERROR)
return FALSE;
ftBootTime = *(FILETIME *)&(SysTimeInfo.BootTime);
FileTimeToLocalFileTime(&ftBootTime,&ftBootTime);
FileTimeToSystemTime(&ftBootTime,pstBootTime);
return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD seconds;
SYSTEMTIME stBootTime;
if(GetUpTime(&stBootTime)) {
_tprintf(
_T("System Uptime: %d/%d/%d %d:%d:%d\n"),
stBootTime.wMonth,
stBootTime.wDay,
stBootTime.wYear,
stBootTime.wHour,
stBootTime.wMinute,
stBootTime.wSecond);
}
return 0;
}
| |
| C/C++ Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | typedef LONG (WINAPI *pNtQuerySystemInformation)(UINT,PVOID,ULONG,PULONG);
typedef struct _SYSTEM_TIME_OF_DAY_INFORMATION
{
LARGE_INTEGER BootTime;
LARGE_INTEGER CurrentTime;
LARGE_INTEGER TimeZoneBias;
ULONG CurrentTimeZoneId;
} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION;
BOOL GetUpTime(SYSTEMTIME *pstBootTime)
{
pNtQuerySystemInformation pfNtQuerySystemInformation;
SYSTEM_TIME_OF_DAY_INFORMATION SysTimeInfo;
FILETIME ftBootTime;
pfNtQuerySystemInformation = (pNtQuerySystemInformation)
GetProcAddress(GetModuleHandle(_T("ntdll")),"NtQuerySystemInformation");
if(!pfNtQuerySystemInformation)
return FALSE;
if(pfNtQuerySystemInformation(3,&SysTimeInfo,sizeof(SysTimeInfo),0) != NO_ERROR)
return FALSE;
ftBootTime = *(FILETIME *)&(SysTimeInfo.BootTime);
FileTimeToLocalFileTime(&ftBootTime,&ftBootTime);
FileTimeToSystemTime(&ftBootTime,pstBootTime);
return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
DWORD seconds;
SYSTEMTIME stBootTime;
if(GetUpTime(&stBootTime)) {
_tprintf(
_T("System Uptime: %d/%d/%d %d:%d:%d\n"),
stBootTime.wMonth,
stBootTime.wDay,
stBootTime.wYear,
stBootTime.wHour,
stBootTime.wMinute,
stBootTime.wSecond);
}
return 0;
}
| |
|
|
|
|