一模一样的code放在DLL中去调用就会出错
直椄copy到程序中不生成DLL调用就没有问题
这是什么问题这个那个函数
Function RunTime(FileToRun : PChar; Var Flag : String; Maxtimes : Extended; Var UseTimes : Extended) : DWord; Export;出问题的应该就是这句
CreateProcess(FileToRun, nil, nil, nil,True,
        CREATE_NEW_CONSOLE, nil, nil, FStartupInfo,FProcessInfo);

解决方案 »

  1.   

    在DELPHI
    帮助里查查Stdcall是什么就知道了,
    它是对参数传递的控制
      

  2.   

    请说清楚一些好嘛 
    我在申明和调用中都加了
    可还是有问题
    Invaild pointer operation
      

  3.   

    dll中一定要有调用方式的,stdcall是标准的。
      

  4.   

    对,我也碰到了这个问题,
    同样的函数申明,stdcall,export,都有,函数返回一个字符串,可是如果result:=result+'03'就要报错了,但是如果只有一个语句:result:='';就不会报错,报错也是Invaild pointer operation
    可是我根本没有指针操作啊,也向楼主一样,函数确实被执行了,就是报错,
    关注中···
      

  5.   

    function aa(cpu,ss:string):string;stdcall;   
    var
     int:integer;
    begin //result:='1';
     int:=0;
     result:=result+ inttohex(int,2);
     //showmessage(cpu+ss);
     result:=cpu+ss;
    end;exports
    aa name 'aa1';
      

  6.   

    DLL里面用String要特别处理的
    新建一个DLL 仔细看看生成的代码里面那一大段英文说明
      

  7.   

    { Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }这东东啊
    算了算了 我不返回string了
    还有一个问题 我还没试
    不过先问一下
    我传给dll中的函数一个参数如var flag: Integer;
    dll中函数运行时 我在外部改变flag的值
    dll中的函数中的那个flag应该也被改变了吧?
    如果不能我应该怎么做呢?
      

  8.   

    是不是说DLL中一边在运行 外面的程序一边在改这个flag?
    这样的话用VAR传递的简单变量应该可以随之变化
    试了以后来说下结果吧
      

  9.   

    感谢TIM兄弟的提醒,我尝试了下,给声明和调用的所有设计到的STRING变为PCHAR类型,就没有报错了
    ,呵呵,满高兴的,