質問編集履歴
1
PowerGetActiveScheme関数の返り値について、電源プランの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -59,3 +59,42 @@
|
|
59
59
|
https://docs.python.org/ja/3/library/ctypes.html
|
60
60
|
|
61
61
|
|
62
|
+
### 追記
|
63
|
+
PowerGetActiveScheme関数の返り値は0です。
|
64
|
+
ご教示願います。
|
65
|
+
|
66
|
+
また、以下のようにして電源プランの変更は行えるようです。
|
67
|
+
|
68
|
+
``` python
|
69
|
+
from ctypes import *
|
70
|
+
|
71
|
+
class GUID(Structure):
|
72
|
+
_fields_ = [("Data1", c_ulong),
|
73
|
+
("Data2", c_ushort),
|
74
|
+
("Data3", c_ushort),
|
75
|
+
("Data4", c_ubyte * 8)]
|
76
|
+
|
77
|
+
|
78
|
+
# PowrProf.dllをロード
|
79
|
+
powersetting = WinDLL("PowrProf")
|
80
|
+
|
81
|
+
# GUID構造体を作成
|
82
|
+
array = c_ubyte*8
|
83
|
+
high_performance = GUID(c_ulong(0x8c5e7fda),
|
84
|
+
0xe8bf,
|
85
|
+
0x4a96,
|
86
|
+
array(0x9a,0x85,0xa6,0xe2,0x3a,0x8c,0x63,0x5c))
|
87
|
+
|
88
|
+
power_save = GUID(c_ulong(0xa1841308),
|
89
|
+
0x3541,
|
90
|
+
0x4fab,
|
91
|
+
array(0xbc,0x81,0xf7,0x15,0x56,0xf2,0x0b,0x4a))
|
92
|
+
|
93
|
+
balance = GUID(c_ulong(0x381b4222),
|
94
|
+
0xf694,
|
95
|
+
0x41f0,
|
96
|
+
array(0x96,0x85,0xff,0x5b,0xb2,0x60,0xdf,0x2e))
|
97
|
+
|
98
|
+
# 電源プランを高パフォーマンスに設定
|
99
|
+
powersetting.PowerSetActiveScheme(None,byref(high_performance))
|
100
|
+
```
|