C# ¿ìËٹػú´úÂë
½ñÌìÓõ½Õâ¸ö£¬ÍøÉÏÕÒ¸ö²»´íµÄ£¬±£´æÏÂÀ´¡£
×¢Ò⣺Õâ¸ö·½·¨ÊÇ¿ìËٹػú£¬²»»á±£´æÄãµÄÈκÎδ±£´æÐÅÏ¢¡£
// Õâ¸ö½á¹¹Ì彫»á´«µÝ¸øAPI¡£Ê¹ÓÃStructLayout
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
// µ¼ÈëµÄ·½·¨±ØÐëÊÇstatic externµÄ£¬²¢ÇÒûÓз½·¨Ìå¡£µ÷ÓÃÕâЩ·½·¨¾ÍÏ൱ÓÚµ÷ÓÃWindows API¡£
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool ExitWindowsEx(int flg, int rea);
// ÒÔ϶¨ÒåÁËÔÚµ÷ÓÃWinAPIʱÐèÒªµÄ³£Êý¡£ÕâЩ³£Êýͨ³£¿ÉÒÔ´ÓPlatform SDKµÄ°üº¬Îļþ£¨Í·Îļþ£©ÖÐÕÒµ½
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
internal const int EWX_SHUTDOWN = 0x00000001;
//internal const int EWX_LOGOFF = 0x00000000;
//internal const int EWX_REBOOT = 0x00000002;
//internal const int EWX_FORCE = 0x00000004;
//internal const int EWX_POWEROFF = 0x00000008;
//internal const int EWX_FORCEIFHUNG = 0x00000010;
// ͨ¹ýµ÷Ó
Ïà¹ØÎĵµ£º
ǰһ¶Îʱ¼äÊÔ×ÅÓÃÕâÈýÖÖÓïÑÔ¼òµ¥µÄдÁ˹ØÓÚÎļþ¿½±´µÄ³ÌÐò£¬·¢ÏÖc#ºÍpythonµÄapi¾ªÈ˵ÄÏàËÆ£¬¶ÔÓÚÎļþµÄ²Ù×÷ÕâÁ½ÖÖÓïÑԷdz£µÄ·½±ã¡£¶¼Ã»ÓмÓÒì³£µÄ´¦Àí
C#Ô´´úÂ룺
public static void CopyFile(string source, string destination)
& ......
µÚÒ»ÖÖ
<%=RetInfo("DB","Êý¾Ý¿â") %>
<%=RetInfo("YX_UpFile","ÉÏ´«Îļþ") %>
<%=RetfileInfo("Include/", "¹ã¸æ")%>
//´Óǰ̨µ÷Óúǫ́·½·¨
//´Óǰ̨µ÷Óúǫ́µÄ·½·¨..²¢ÏòÆä·½·¨´«È벻ͬµÄ²ÎÊý!
µÚ¶þÖÖ
<ItemTemplate >
<%#Ret_stat(Convert.ToInt16(Eval("YX_Stat1")), "Èȵã")%>
......
ͨ¹ýxslת»»´óxmlÎļþ
Õ⼸ÌìÔÚ×öÕâ¸ö£¬ÍøÉϵö·½·¨ÎÒ¶¼ÊÔ¹ýÁË£¬»ã×ÜÈçÏÂ
·½·¨Ò»£º
XPathDocument myXPathDoc = new XPathDocument(tbXMLFile.Text);
XslCompiledTransform myXslTrans = new XslCompiledTransform();
myXslTrans.Load(tbXSLFile.Text);
XmlTextWriter myWriter = new XmlTextWrit ......
XmlDocument doc = new XmlDocument();
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
doc.AppendChild(dec);
//´´½¨Ò»¸ö¸ù½Úµã£¨Ò»¼¶£©
XmlElement root = doc.CreateElement("First");
doc.AppendChild(root);
//´´½¨½Úµã£ ......
//ÃüÃû¿Õ¼ä using Microsoft.Win32;
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox2.Checked) //ÉèÖÿª»ú×ÔÆô¶¯
{
//MessageBox.Show ("ÉèÖÿª»ú×ÔÆô¶¯ÐèÒªÐÞ¸Ä×¢²á±í","Ìáʾ");
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMac ......