From cbd943016aaf7160224dbf4ebfc79cfc48ac32ac Mon Sep 17 00:00:00 2001 From: WAKAYAMA Shirou Date: Thu, 3 Sep 2015 21:59:24 +0900 Subject: [PATCH] process[windows]: implement CreateTime. --- process/process_windows.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/process/process_windows.go b/process/process_windows.go index 1c02932..cca6fd7 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -147,6 +147,23 @@ func (p *Process) Cmdline() (string, error) { } return *dst[0].CommandLine, nil } +func (p *Process) CreateTime() (int64, error) { + var dst []Win32_Process + query := fmt.Sprintf("WHERE ProcessId = %d", p.Pid) + q := wmi.CreateQuery(&dst, query) + err := wmi.Query(q, &dst) + if err != nil { + return 0, err + } + if len(dst) != 1 { + return 0, fmt.Errorf("could not get CreationDate") + } + date := *dst[0].CreationDate + return date.Unix(), nil + + return 0, common.NotImplementedError +} + func (p *Process) Cwd() (string, error) { return "", common.NotImplementedError }