应该把unit1加入Unit2的uses区

解决方案 »

  1.   

    1.在unit1中的interface节中声明GetExepath函数
    2.如Michaelyfj所说
      

  2.   

    不行,我在unit1加入unit2的uses区,用GetExePath和GetExePath()有区别吗?我认为没有!
      

  3.   

    用Unit1.GetExePath();试试看出现什么异常信息。
      

  4.   

    不行,我在unit1加入unit2的uses区,用GetExePath和GetExePath()有区别吗?我认为没有!
      

  5.   

      function GetExePath: String
    改为
    proceudre TForm1.GetExePath:
      

  6.   

      function GetExePath: String
    改为
    proceudre TForm1.GetExePath:string   
      

  7.   

    “我在unit1加入unit2的uses区”,这话是什么意思?是将unit1的Inteface区‘Uses Unit2'还是在Unit2的Inteface区"uses Unit1"?
    按你的要求而言应该是在Unit2的Inteface区或者Implementaltion区的最前面"Uses Unit1";应该不会有任何问题。
    如果没有参数,getexePath与getExePath()没有区别。 
      

  8.   

    我用unit1.GetExePath可以,但我定义的是全局函数,有那位知道直接可以调用GetExePath而不用
    加unit1!!!
      

  9.   

    那你只有将getexepath定义在unit2单元了,再说了,干吗要写函数呢,application.exename不是现成的吗?
      

  10.   

    既然用Unit1.GetExePath可以,而用GetExePath不行,那看定是你没有Uses好!你的Unit2的Uses语句中没有Unit1。
      

  11.   

    你在unit1中一定是只定义而没有声明
    所以才会导致这样var
      form1:tform1;
      function GetExePath: String;<------------别忘了这一句implementation
    {$R *.dfm}function GetExePath: String;
    begin
      .....
    end;