VC++
MSDN: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(EXITWINDOWSEX);k(DevLang-%22C%2B%2B%22)&rd=true
#include "stdafx.h"
#include "Windows.h"
#include "Winuser.h"
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
printf("Failed to get the token for this process");
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
printf("Failed to adjust the token privileges.");
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE,
SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
SHTDN_REASON_MINOR_UPGRADE |
SHTDN_REASON_FLAG_PLANNED))
printf("Failed to Shut Down the system.");
return 0;
}
訂閱:
張貼留言 (Atom)
Python notes: Calculate delay time by WinDBG log
用WinDBG開Event Timestamps可以產生下面格式的log: Fri Sep 21 18:43:50.946 2018 (UTC + 8:00): @#$#^$@#$^ 以下python code用來找出兩個指定log中的時間差
-
因特別需求家中裝了很多無線設備,也不知道為什麼家中的中華電信數據機三不五時就會斷線,斷電再重新通電後又會恢復正常。又因為家裡不是隨時都有人可以幫忙處理,於是冒出了這個想法,要是有個設備可以自動偵測我的無線網路連線,當網路斷線時自動把AP的電源切斷,過個幾秒在通電,這樣就不用怕AP...
-
今天照著mobile01的教學文把我的Incredible S預載的台灣大哥大無用軟體關閉了 在此做個筆記... 其實這支手機剛買來時就做過一樣的事了 但因年前HTC釋出了Android 2.3.5的更新, 使我已經ROOT的手機又再經過S-ON後復原 更新到Android 2....
-
最近買了房子, 身為勤儉持家的客家子弟怎麼可能去請室內設計師來呢 我要自己來! Google到這隻專門繪製室內格局圖的程式, 作者好像是個法國人, 有簡體中文的版本, 還是免費版的唷!
沒有留言:
張貼留言
Thanks for your message.