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 ?
attribute - creation date
Re: attribute - creation date
The EnumChildWindows function itself does not provide direct access to the creation date of the windows it enumerates.
I obtained the following information through perplexity.ai
a simplified example in C
Regards,
Tom.H.
I obtained the following information through perplexity.ai
a simplified example in C
Code: Select all | Expand
#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;
}
Regards,
Tom.H.
Re: attribute - creation date
Thanks ! I solve this problem like this - request processes of a certain type through WMi and compare them .CreationDate
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: attribute - creation date
Dear Yuri,
Would you mind to share that code to help other users ?
many thanks
Would you mind to share that code to help other users ?
many thanks
Re: attribute - creation date
I check the same type of processes (e.g. Excel) roughly like this:
Code: Select all | Expand
#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()