BOOL MySystemShutdown()但是是用SDK 寫的。
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return( FALSE );
// 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)
return FALSE;
// 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))
return FALSE;
return TRUE;
}
要找一找這些typedef的原型是甚麼...
可以用Visual Studio , New 一個Win32App,加入API Name,就可以用 Go to Definition .. 到declaration 的地方Visual Studio 和 CodeWarrior, SourceInsight 不一樣,winbase.h
不需要build project就可以做到cross-ref edit(browse)HANDLE GetCurrentProcess( ) : kerne32.dll這麼多typedef ,怎麼找 @_@....
BOOL OpenProcessToken ( // int
HANDLE ProcessHandle, // void*
DWORD DesiredAccess, // unsigned long
HANDLE* TokenHandle // void**
) : advapi32.dll
winbase.h
BOOL LookupPrivilegeValue : ( // int
LPCTSTR lpSystemName, // wchar_t
LPCTSTR lpName, // wchar_t
PLUID lpLuid // ----- structre
) : advapi32.dll
typedef struct _LUID {
DWORD LowPart; // unsigned long
LONG HighPart; // long
} LUID, *PLUID;
win
BOOL AdjustTokenPrivileges( // int
HANDLE TokenHandle, // void
BOOL DisableAllPrivileges, // int
PTOKEN_PRIVILEGES NewState, // --- structure
DWORD BufferLength, // unsigned long
PTOKEN_PRIVILEGES PreviousState, // --- structure
PDWORD ReturnLength // unsigned long
) : advapi32.dll
typedef struct _TOKEN_PRIVILEGES {
DWORD PrivilegeCount; // unsigned long
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; // --- structure, ANYSIZE_ARRAY = 1
} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
typedef struct _LUID_AND_ATTRIBUTES {
LUID Luid; // --- structure - prev
DWORD Attributes; // unsigned long
} LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
winbase.h
WINBASEAPI
DWORD // unsigned long
WINAPI
GetLastError() : kernel32.dll
winuser.h
BOOL WINAPI ExitWindowsEx( // int
UINT uFlags, // unsigned int
DWORD dwReason // unsigned long
) : user32.dll
利用Visual Studio來找... Create一個Win32 Form App.
到sourcecode...按右鍵就有 - Goto Definition.
在windef.h中有定義
HANDLE : void*
BOOL : int
DWORD : unsigned long
...其實直接在Visual Studio中用 Go to Definition..反覆 就可以到 type definition的地方。
星期三, 7月 05, 2006
More on Shutdown
這一篇msdn是Shutdown的步驟 :
訂閱:
張貼留言 (Atom)
網誌存檔
-
▼
2006
(434)
-
▼
7月
(70)
- Windows2003 遠端桌面連線
- Flac - encoding
- 糟糕...亂搞的結果...
- try .. blogspace 中文?
- reseal - Part II
- ToDo List..
- 使用NTLDR boot DOS
- ghost 2003 seems using xpe..
- complain - about tool's version and ghost...
- Cloning XPE Image - Reseal
- TUX magazine is going be be Not-free
- google maps, Wikipedia - about this WWIII
- EWF : Enhance Write Filter - what XPE differ from XP
- Some Helping Utility for building XP Embedded
- XPE : Minlogon - login automatically with system user
- Research,, and waiting to be bought..
- C++ GUI Programming with Qt 4
- 颱風 - 凱米
- wavpack : hybrid
- 這個布丁也好吃的
- 默默..
- 蠻好喝的健酪 藍莓
- XP Boot Process
- Need Some Space for EWF
- TAP.EXE : different result in differnet environment
- why Reiser4 is not in the kernel
- DirectX 2006/6 download path
- keroro mp3 player
- 愚蠢! 原來是Power的問題
- Site Memo : chroot.org : Taiwan Hacker's org
- fotocom cd 350 - usb hd box - sucks
- C3VCM6 - VIA C3/C7 mini-ATX
- 使特林引擎,3500 NT -- 真想買
- turn on ATX Power without using Mainboard.
- 不要在註冊時留下任何個人資料..
- Skype Protocol has been cracked
- keroro - 全員敬禮..
- billing machine run Windows
- find source site with netselect-apt
- retrieve another character encoding archieve
- delete unqualified named folder in Windows
- Full Read-Write Linux NTFS Driver : OpenSource
- some problem about QCOM
- more .. about Marketing..
- boot CE on VMWARE via SBOOT
- Virtual Floppy Disk : VFD - Opensource software
- bootloader for CE x86 platform
- Debian Sarge Testing.. support VMWARE share USB
- CE 5.0 Platform Builder - some idea...
- Something about platform builder : build process
- CE Platform Builder Installation
- 不好吃 : 辣白菜拉麵
- Porting FlashPlyer to Linux : a real hard thing.
- How do that know the real marketsize ?
- X protocol - begin
- 北韓如何挽回經濟,賺取外匯?
- devfs is gone
- Success - Shutdown Windows, in C++ with ExitWindowsEx
- More on Shutdown
- .NET and COM : Interoperability
- More about Interop in Managed , Unmanaged C++
- Shutdown Windows in VC++ 2003 with CLR
- ^ and gcnew : not MS specific, a New C++ standard
- some googling about anubis gates
- SerialPort Class in .NET Framework - finally
- Visual C++ Express
- VC Express and Platform SDK
- ffmpeg : probe - mpegts
- Visual Studio Express - installtion
- The Anubis Gates (捏他)
-
▼
7月
(70)
沒有留言:
張貼留言