C#取exe文件绝对路径

 

using System.Runtime.InteropServices;
#region
///
<summary> /// 取exe文件绝对路径 /// </summary> /// <param name="hModule"></param> /// <param name="lpFileName"></param> /// <param name="nSize"></param> /// <returns></returns> [DllImport("kernel32")] public static extern int GetModuleFileName(IntPtr hModule, [Out] StringBuilder lpFileName,int nSize); #endregion
#region
IntPtr processHandle = IntPtr.Zero;
StringBuilder exeFileNamestrB = new StringBuilder(260);
GetModuleFileName(processHandle, exeFileNamestrB, exeFileNamestrB.Capacity);
#endregion

 

C#取exe文件绝对路径

上一篇:Windows Server 2012 R2 辅助域控制器搭建


下一篇:XMind 2021思维导图 完美中文免费版(Win+Mac)