RSS 2.0 Feed
2004-12 Entries

为什么Xml是大小写敏感的? Marriage Proposal 监狱问题

posted @ | Feedback (20) | Filed Under [ 虎说八道 二进制生活 ]

摘要:      最近为了方便重起某些远程 Server,写了个重起机器的Web Service,调用user32.dll 的ExitWindowsEx 来重启机器。 从Win2K 开始,在调用ExitWindowsEx 之前需要先调用AdjustTokenPrivileges 设置Privilege,说实话在C#里做这个挺麻烦的说,还好 Goolge 了一下,在MS Newsgroup 里找到了别人的代码 internal class TokenAdjuster { [DllImport("user32.dll")] internal static extern bool ExitWindowsEx(int uFlags,int dwReserved); // PInvoke stuff required to set/enable security privileges [DllImport("advapi32", SetLastError=true)] [SuppressUnmanagedCodeSecurity] static extern int OpenProcessToken( IntPtr ProcessHandle, // handle to process int DesiredAccess, // desired access to process ref IntPtr TokenHandle // handle to open access token ); [DllImport("kernel32", SetLastError=true)] [SuppressUnmanagedCodeSecurity] static extern bool CloseHandle(IntPtr handle); [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)] [SuppressUnmanagedCodeSecurity] static extern int AdjustTokenPrivileges( ......[阅读全文]

posted @ | Feedback (4) | Filed Under [ 二进制生活 ]