Hi,
I need to detect the appearance of some window on the screen. For this purpose I use EnumChildWindows.
Do the checked windows (or the processes that created them) have an attribute - creation date ?
#include <windows.h>
#include <stdio.h>
void GetProcessCreationTime(HWND hwnd) {
DWORD processId;
// Get the process ID of the window
GetWindowThreadProcessId(hwnd, &processId);
// Open the process to query information
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processId);
if (hProcess) {
FILETIME creationTime, exitTime, kernelTime, userTime;
// Get the process time information
if (GetProcessTimes(hProcess, &creationTime, &exitTime, &kernelTime, &userTime)) {
SYSTEMTIME st;
// Convert FILETIME to SYSTEMTIME
FileTimeToSystemTime(&creationTime, &st);
// Output the creation time
printf("Creation Time: %04d-%02d-%02d %02d:%02d:%02d\n",
st.wYear, st.wMonth, st.wDay,
st.wHour, st.wMinute, st.wSecond);
} else {
printf("Failed to get process times.\n");
}
// Close the process handle
CloseHandle(hProcess);
} else {
printf("Failed to open process. Error: %lu\n", GetLastError());
}
}
int main() {
// Example: Get the creation time of the desktop window
HWND hwnd = GetDesktopWindow();
GetProcessCreationTime(hwnd);
return 0;
}
#INCLUDE "FiveWin.ch"
procedure Main
local dim:=Lst_Pss("EXCEL.EXE")) //list process
if len(dim)>0
atail(dim):CreationDate
endif
return
FUNCTION Lst_Pss(pss)
local dim:={}
local oList, oProc
** pss - application name
oWmi:= WmiService()
oList:= oWmi:ExecQuery( "select * from Win32_Process where Name = '" + pss + "'" )
for each oProc in oList
aadd(dim, oProc)
next
return dim
function WMIService()
local oLocator := CREATEOBJECT( "wbemScripting.SwbemLocator" )
return oLocator:ConnectServer()
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 43 guests