summaryrefslogtreecommitdiffstats
path: root/base/process_info_win.cc
blob: 762961fc3364b0066afe44ddca20ed3e63b68998 (plain)
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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/process_info.h"

#include <windows.h>

#include "base/basictypes.h"
#include "base/time.h"

namespace {

using base::Time;

// Returns the process creation time, or NULL if an error occurred.
Time* ProcessCreationTimeInternal() {
  FILETIME creation_time = {};
  FILETIME ignore = {};
  if (::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore,
      &ignore, &ignore) == false)
    return NULL;

  return new Time(Time::FromFileTime(creation_time));
}

}  // namespace

namespace base {

//static
const Time* CurrentProcessInfo::CreationTime() {
  static Time* process_creation_time = ProcessCreationTimeInternal();
  return process_creation_time;
}

}  // namespace base