badboy518 发表于 2012-8-4 10:46:00

取得本dll路径的方法及按键Hook的方法


public static class Xsys
{
    ///
    /// 取得本dll的路径
    ///
    ///
    public static string GetAssemblyPath()
    {
      string _CodeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
      _CodeBase = _CodeBase.Substring(8, _CodeBase.Length - 8);    // 8是 file:// 的长度
      string[] arrSection = _CodeBase.Split(new char[] { '/' });
      string _FolderPath = "";
      for (int i = 0; i 复制代码

chpmould 发表于 2012-8-4 16:50:00

获取的路径没有程序名称

badboy518 发表于 2012-8-4 22:10:00

第11行时,已取得成功。只是我故意做的过滤,只取路径

zlg258369 发表于 2012-8-5 23:15:00

这样行不行
string _CodeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase
_CodeBase.Substring(0 , _CodeBase.LastIndexOf('\') )

badboy518 发表于 2012-8-7 08:37:00

可能更好,

huaxiamengqing 发表于 2012-9-6 12:57:00

Dim Mnetp As String = Microsoft.VisualBasic.Compatibility.VB6.Support.GetPath()
      Dim Mnetn As String = Microsoft.VisualBasic.Compatibility.VB6.Support.GetEXEName()
simple and work well! Though old.

/ty天涯/ty 发表于 2012-9-17 14:31:00

请问一下您是CAD200几的,我2008的好像不行!
页: [1]
查看完整版本: 取得本dll路径的方法及按键Hook的方法