该dll名称可修改!

解决方案 »

  1.   

    ShowMessage(Application.ExeName);  //Application为Dll
      

  2.   

    <a href="http://fengyebar.cn.st">实例</a>
      

  3.   

    function GetDllFileName: String;
    var
       intSize: Integer;
       arrPath: array[0..260] of Char;
    begin
       FillChar(arrPath, SizeOf(arrPath), 0);
       intSize := GetModuleFileName(HInstance, arrPath, 260);
       arrPath[intSize] := #0;
       result := arrPath;
    end;
      

  4.   

    得到路径:ExtractFilePath(GetDllFileName);
      

  5.   

    FrameSniper(人类不能不吃饭@手机不能不充电.net):
       ShowMessage(Application.ExeName);  // 返回调用 Dll 进程的文件名
      

  6.   

    我的意思是在dll程序中,找到本身dll的名字?
      

  7.   

    你有没有试我的代码??不试试就在瞎喊!!!我的那段代码返回的就是 Dll 本身的文件名(绝对路径)。
      

  8.   

    kyee(浪子阿鹏) ( ) 
    不好意思,我的dll是webservices,放在虚拟目录下,配置文件也在该虚拟目录下,我的程序通过activeform调用该dll.
    你的方法得到的是dllhost.exe,和extractfilepath(paramstr(0))效果一样,不是我调用的dll文件名
      

  9.   

    Sorry! 我没有在 webservices 中试过, 普通的 Dll 用我的方法是可以的, 试试下面的:
    function GetActiveDllFileName: String;
    var
       intSize: Integer;
       arrPath: array[0..260] of Char;
    begin
       FillChar(arrPath, SizeOf(arrPath), 0);
       intSize := GetModuleFileName(FindHInstance(@GetActiveDllFileName), arrPath, 260);
       arrPath[intSize] := #0;
       result := arrPath;
    end;
      

  10.   

    GetDllFileName, GetActiveDllFileName 函数一定要放在 Dll 中, 切记!