[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfdefs_win.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfdefs_win.cpp
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfdefs_win.cpp 978 2016-12-31 05:16:11Z phfaist $ */
23 
29 #include <klfdefs.h>
30 #include <klfsysinfo.h>
31 
32 #include <windows.h>
33 
34 #if defined(_M_IX86)
35 static const char * arch = "x86";
36 #elif defined(_M_AMD64)
37 static const char * arch = "x86_64";
38 #elif defined(_WIN64)
39 static const char * arch = "win64";
40 #else
41 static const char * arch = "unknown";
42 #error "Unknown Processor Architecture."
43 #endif
44 
46 {
47  return QString::fromLatin1(arch);
48 }
49 
50 
52 {
54 
55  SYSTEM_POWER_STATUS batterystatus;
56 
57  if (GetSystemPowerStatus(&batterystatus) == 0) {
58  klfWarning("Could not get battery status.") ;
59  info.islaptop = false;
60  info.onbatterypower = false;
61  return info;
62  }
63 
64  info.islaptop = (batterystatus.ACLineStatus != 255);
65  info.onbatterypower = false;
66  if (batterystatus.ACLineStatus == 0)
67  info.onbatterypower = true;
68 
69  return info;
70 }
71 
73 {
75  info = _klf_win_battery_info();
76  return info.islaptop;
77 }
78 
80 {
82  info = _klf_win_battery_info();
83  return info.onbatterypower;
84 }
85 
KLF_EXPORT KLFSysInfo::BatteryInfo _klf_win_battery_info()
Definition: klfdefs_win.cpp:51
Base declarations for klatexformula and some utilities.
KLF_EXPORT bool _klf_win_is_laptop()
Definition: klfdefs_win.cpp:72
#define KLF_EXPORT
Definition: klfdefs.h:41
#define klfWarning(streamableItems)
QString fromLatin1(const char *str, int size)
KLF_EXPORT bool _klf_win_is_on_battery_power()
Definition: klfdefs_win.cpp:79
KLF_EXPORT QString klf_defs_sysinfo_arch()
Definition: klfdefs_win.cpp:45

Generated by doxygen 1.8.13