24小时热门版块排行榜    

查看: 1667  |  回复: 7
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

orential

木虫 (小有名气)

[求助] 建立单文档MFC的工程怎么调用DLL文件

VC++6.0????????MFC.exe????????????????????ɡ??????DLL??????????????????????????????????????????????win32?????????????????????????DOS???????
?????λ???????????????MFC.exe???????????DLL?????????????MFC?а????????????????????????????????????????
CODE:
#include
#include
#include "REFPROP1.H"

// Some constants...

const long refpropcharlength=255;
const long filepathlength=255;
const long lengthofreference=3;
const long errormessagelength=255;
const long ncmax=20;      // Note: ncmax is the max number of components
const long numparams=72;
const long maxcoefs=50;

int main(int argc, char* argv[])
{

// First create a pointer to an instance of the library
// Then have windows load the library.
HINSTANCE RefpropdllInstance;
//This looks only in the current directory for refprop.dll
???????X?e?N?X????Instance = LoadLibrary("./refprop.dll");

// Then get pointers into the dll to the actual functions.
  ABFL1dll = (fp_ABFL1dllTYPE) GetProcAddress(RefpropdllInstance,"ABFL1dll");
  ABFL2dll = (fp_ABFL2dllTYPE) GetProcAddress(RefpropdllInstance,"ABFL2dll");
  ACTVYdll = (fp_ACTVYdllTYPE) GetProcAddress(RefpropdllInstance,"ACTVYdll");
  AGdll = (fp_AGdllTYPE) GetProcAddress(RefpropdllInstance,"AGdll");
  

// Now use the functions.

// Refprop variables that need to be defined
//
// nc = Number of components in the mixture
// x[NumberOfComponentsInMixtures] = Mole fraction of each component
// ierr =An integer flag defining an error
// hf[] = a character array defining the fluids in a mixture
// hrf[] = a character array denoting the reference state
// herr[] = a character array for storing a string - Error message
// hfmix[] a character array defining the path to the mixture file

  ???N?I????? x[ncmax],xliq[ncmax],xvap[ncmax],f[ncmax];

  long i,ierr;
  char hf[refpropcharlength*ncmax], hrf[lengthofreference+1],
  ????e?e????e?e?N?e????Q?Q????????`??H??+1],hfmix[refpropcharlength+1];

  //Exlicitely set the fluid file PATH
  //char *FLD_PATH;
  //FLD_PATH = "C:\\Program Files\\REFPROP\\fluids\\";
//    strcpy(hf,FLD_PATH);
//    strcpy(hfmix,FLD_PATH);

    //...initialize the program and set the pure fluid component name
  //i=1;
  //strcpy(hf,"nitrogen.fld");
  //strcpy(hfmix,"hmx.bnc");
  //strcpy(hrf,"DEF");
  //strcpy(herr,"Ok");

//...For a mixture, use the following setup instead of the lines above.
  // Use "|" as the file name delimiter for mixtures
  ??=3;
  ?Q?H?e???X??(hf,"nitrogen.fld");
    strcat(hf,"|argon.fld");
    strcat(hf,"|oxygen.fld");
  ?Q?H?e???X??(hfmix,"hmx.bnc");
  ?Q?H?e???X??(hrf,"DEF");
    strcpy(herr,"Ok");
    x[0]=.7812; //Air composition
  ????1]=.0092;
  ????2]=.2096;

    //...Call SETUP to initialize the program
      SETUPdll(i, hf, hfmix, hrf, ierr, herr,
          ?e?????X?e?N?X?????e????`??H??*ncmax,refpropcharlength,
          ????`??H???N???e??????e??`????,errormessagelength);
      if (ierr != 0) printf("%s\n",herr);

      double wm,ttp,tnbp,tc,pc,dc,zc,acf,dip,rgas;
      long info_index=1;
      INFOdll(info_index,wm,ttp,tnbp,tc,pc,dc,zc,acf,dip,rgas);
      printf("WM,ACF,DIP,TTP,TNBP ??10.4f,%10.4f,%10.4f,%10.4f,%10.4f\n",wm,acf,dip,ttp,tnbp);
      printf("TC,PC,DC,RGAS   ??10.4f,%10.4f,%10.4f,%10.4f,%10.4f\n",tc,pc,dc,rgas);
//...Calculate molecular weight of a mixture
// ?b??=WMOLdll(x)

//...Get saturation properties given t,x; for i=1: x is liquid phase
//.....           ???N?e i=2: x is vapor phase

  ???N?I????? t=100.0;
    double p,dl,dv;

  ??ATTdll(t,x,i,p,dl,dv,xliq,xvap,ierr,herr,errormessagelength);
  ?X?e???`?H??("P,Dl,Dv,xl[0],xv[0] ??10.4f,%10.4f,%10.4f,%10.4f,%10.4f\n",p,dl,dv,xliq[0],xvap[0]);
  ??=2;
  ??ATTdll(t,x,i,p,dl,dv,xliq,xvap,ierr,herr,errormessagelength);
  ?X?e???`?H??("P,Dl,Dv,xl[0],xv[0] ??10.4f,%10.4f,%10.4f,%10.4f,%10.4f\n",p,dl,dv,xliq[0],xvap[0]);

//...Other routines are given in UTILITY.FOR


return 0;
}
[color=Red]Sample Text[/color]4]Sample Text[/size]
typedef void (__stdcall *fp_ABFL1dllTYPE)(double &,double &,double *,long &,double &,double &,double &,double &,double &,double &,long &,char*,long );
typedef void (__stdcall *fp_ABFL2dllTYPE)(double &,double &,double *,long &,long &,double &,double &,double &,double &,double &,double &,double &,double *,double *,double &,double &,double &,double &,double *,double *,double &,long &,char*,long );
typedef void (__stdcall *fp_ACTVYdllTYPE)(double &,double &,double *,double &);
typedef void (__stdcall *fp_AGdllTYPE)(double &,double &,double *,double &,double &);


//Define explicit function pointers
fp_ABFL1dllTYPE ABFL1dll;
fp_ABFL2dllTYPE ABFL2dll;
fp_ACTVYdllTYPE ACTVYdll;
fp_AGdllTYPE AGdll;

[ Last edited by jjdg on 2012-12-19 at 03:35 ]
回复此楼
落花虽有意,锄头本无情
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

胡树坚

新虫 (初入文坛)

【答案】应助回帖

感谢参与,应助指数 +1
实在不能帮你,全是乱码,如果可以的话,可以百度一下看看DLL的用法
3楼2012-12-17 20:34:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 8 个回答

orential

木虫 (小有名气)

怎么代码粘到里面变成乱码了
落花虽有意,锄头本无情
2楼2012-12-16 21:33:53
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

orential

木虫 (小有名气)

引用回帖:
3楼: Originally posted by 胡树坚 at 2012-12-17 20:34:44
实在不能帮你,全是乱码,如果可以的话,可以百度一下看看DLL的用法

谢谢围观,不知道为什么黏贴进来就成乱码了
落花虽有意,锄头本无情
4楼2012-12-18 09:28:25
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhanglinfeng

新虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
首先要包含你所要连接的动态连接库的头文件,然后在设置标签下有连接选项,然后在最后输入你索要连接的动态连接库的名称
5楼2012-12-18 18:47:45
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见