由于工作需要,在程序中调用了其它公司提供的动态库,当使用动态调用时没有问题,如果改为静态调用,当程序退出时就会出现“程序.exe faulted with message:'access violation as 0x000000100 : read of address 0x000000100'.process stopped.uses step or run to continue”
已经试过很多方法修改我的程序都没有解决,请问这是我的问题还是动态库编写的问题?

解决方案 »

  1.   

    静态调用的话,是不执行 dllmain 函数。
    一些库的初始化的东东都在 dllmain 里面执行了。只有动态的调用才能正确使用。如果得不到动态库的源代码和使用文档,动态调用是最保险的
      

  2.   

    个人喜好,不喜欢动态调用,写的代码太多,而且这些DLL是需要频繁调用的。在提供的动态库中要求程序启动时需要先调用初始化函数,调用后程序退出就会出错。
    能不能在我的程序退出前执行一些代码,使其不出现错误提示?
      

  3.   

    程序退出就会出错,说明程序不是很稳定,使其不出现错误提示,这个方法不建议使用。
    有错误最好不要隐藏。
    如果你知道动态库的执行过程,可以在开始的时候执行初始化代码,退出的时候执行释放代码。如果动态调用和静态调用都可以的话,可以根据个人喜好。
     这些DLL是需要频繁调用的跟动态调用和静态调用没有关系,动态调用载入一次也是可以的。
     代码也不会太多,静态调用你需要写函数声明的头文件跟你写一个函数指针的头文件区别不大。
      

  4.   

    请大家关注http://community.csdn.net/Expert/topic/5679/5679347.xml?temp=7.767886E-02
    等待散分
      

  5.   

    I get an "Error loading MIDAS.dll" error when starting PractiCount and the program refuses to work properly after that.It seems the midas.dll library does not install automatically for some reason. Try to close PractiCount, unzip the downloaded midas.dll file and put it into the c:\windows\system32\ (c:\winnt\system32\) folder. You might also need to manually register midas.dll. To do this you need to open Start>Run and copy there this text: regsvr32.exe c:\windows\system32\midas.dll (or regsvr32.exe c:\winnt\system32\midas.dll, depending on your system) and press OK. After that launch PractiCount.
      

  6.   

    重新下载一个
    http://www.practiline.com/download/midas.zip
      

  7.   

    先谢谢各位的帮助,在没有办法的情况下使用动态调用已经解决了第一步初始化的问题,在接下来的工作中需要调用动态库中的函数从对方的数据库中取出数据,以下是函数定义:
    int FunctionName ( char *  Sname, Char*  DataBuffer )
    其中DataBuffer是传出参数,用动态调用的方法传入PChar类型的变量结果还是出错,请各位帮我分析一下问题可能出在哪里。我先调用了DataBuffer := StrAlloc(2000*Sizeof(Char)),可是无论有没有这一行都不行。