2019年12月5日 星期四

Windows 解除非預期的喚醒

1. 關閉 網路喚醒


2. 關閉 USB喚醒


3. 設定電源選項


將電源計劃設為預設值

停用喚醒計時器
禁用喚醒定時器

參考資料:


4. 關閉 排程 的 喚醒


指令powercfg /waketimers

確認有哪些排程喚醒

使用PSTools,可以在微軟網站上下載。
https://docs.microsoft.com/zh-cn/sysinternals/downloads/pstools

指令
psexec -i -s -d mmc.exe /s taskschd.msc

參考資料:
https://zhuanlan.zhihu.com/p/67930133


※ 註:

powercfg -lastwake 可以查看最近喚醒電腦的原因






2019年12月1日 星期日

Visual C++/CLR 之 Json.NET 範例

安裝教學


Visual C++/CLR 使用 NuGet 套件 - 以Json.Net 為例
https://youtu.be/WujKlfNyL8I


 序列化 


#include <string>
using namespace std;

using namespace System;

using namespace Newtonsoft::Json;

public ref class Account : Object
{
public:
bool Active;
String^ Email;
};

int main()
{
Account^ account = gcnew Account();
account->Email = "kaihao@example.com";
account->Active = true;

String^ json = JsonConvert::SerializeObject(account, Formatting::Indented);

Console::WriteLine(json);
Console::ReadKey();

return 0;
}


 反序列化 


#include <string>
using namespace std;

using namespace System;
using namespace System::IO;
using namespace System::Collections::Generic;

using namespace Newtonsoft::Json;

public ref class PeopleData : Object
{
public:
String^ Part;
List<List<float>^>^ Points;
};

int main()
{
String^ jsonFile = File::ReadAllText(R"(C:\Users\KaiHao\Desktop\1GM318J6\size.txt)");

List<PeopleData^>^ peopleDatas = JsonConvert::DeserializeObject<List<PeopleData^>^>(jsonFile, (JsonSerializerSettings ^)nullptr);

Console::ReadKey();

return 0;
}