24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1802  |  回复: 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的回帖

orential

木虫 (小有名气)

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

胡树坚

新虫 (初入文坛)

【答案】应助回帖

感谢参与,应助指数 +1
实在不能帮你,全是乱码,如果可以的话,可以百度一下看看DLL的用法
3楼2012-12-17 20:34:44
已阅   回复此楼   关注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的回帖

orential

木虫 (小有名气)

引用回帖:
5楼: Originally posted by zhanglinfeng at 2012-12-18 18:47:45
首先要包含你所要连接的动态连接库的头文件,然后在设置标签下有连接选项,然后在最后输入你索要连接的动态连接库的名称

你这个是隐式调用吧,我是要显示调用DLL的,因为软件提供的DLL是封装好的。
落花虽有意,锄头本无情
6楼2012-12-19 10:55:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

君子之交437

金虫 (小有名气)

请问您的这个问题解决了吗,小弟我也遇到了和您一样的问题,想请教您一下,行吗

[ 发自手机版 http://muchong.com/3g ]
7楼2013-05-11 03:28:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

coralmaomao

新虫 (初入文坛)

楼主,我用的同样的接口出现了access voilation 错误,求帮忙!非常感谢!!!!
8楼2015-06-06 11:06:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 orential 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703化学 +20 妮妮ninicgb 2026-04-04 23/1150 2026-04-06 23:06 by chenzhimin
[考研] 一志愿哈工大,初试329,求环境科学与工程调剂! +6 余未辛 2026-04-06 6/300 2026-04-06 20:51 by lbsjt
[考研] 0703总分331求调剂 +12 ZY-05 2026-04-04 16/800 2026-04-06 17:54 by lijunpoly
[考研] 0857大类环境工程B区求调剂 +3 龚禹铭 2026-04-05 3/150 2026-04-06 10:22 by 蓝云思雨
[考研] 319求调剂 +3 handrui 2026-04-05 3/150 2026-04-06 09:33 by jp9609
[考研] 308求调剂 +3 终不似从前 2026-04-05 3/150 2026-04-05 22:23 by hemengdong
[考研] 考研调剂生寻找导师 +3 顾瞻考研啊 2026-04-05 3/150 2026-04-05 18:18 by 啵啵啵0119
[考研] 求调剂到0856材料工程 +3 程9915 2026-04-05 3/150 2026-04-05 18:15 by 蓝云思雨
[考研] 材料化工306分找合适调剂 +14 沧海轻舟e 2026-04-04 14/700 2026-04-05 09:53 by 朱云虎202
[考研] 调剂 +11 JLLLLLLLLLL 2026-04-03 11/550 2026-04-04 22:21 by hemengdong
[考研] 085600调剂 +4 1amJJ 2026-04-02 4/200 2026-04-04 21:53 by hemengdong
[考研] 求调剂,一志愿南京航空航天大学 ,080500材料科学与工程学硕 +10 @taotao 2026-04-03 10/500 2026-04-04 09:01 by T可可西里T
[考研] 一志愿重庆大学085404,总分314分,求调剂 +4 zf83hn 2026-04-03 4/200 2026-04-03 21:25 by 啵啵啵0119
[考研] 调剂 +5 asdasdassda 2026-04-03 6/300 2026-04-03 20:27 by 岸上的一条鱼
[考研] 338求调剂,一志愿能源动力,外语是日语203 +5 zzz,,r 2026-04-02 5/250 2026-04-03 09:45 by 蓝云思雨
[考研] 一志愿大工学硕,求调剂 +4 yub0811 2026-04-02 4/200 2026-04-02 21:36 by 百灵童888
[考研] 318求调剂 +3 笃行致远. 2026-03-31 4/200 2026-04-02 15:56 by Jaylen.
[考研] 一志愿北京科技大学材料学硕328分求调剂 +6 1段时间 2026-03-31 7/350 2026-04-02 13:57 by 3041
[考研] 0710生物学求调剂 +9 manman511 2026-04-01 9/450 2026-04-02 10:00 by zxl830724
[硕博家园] 博一被送出联培感觉不适应怎么办 +3 全村的狗 2026-03-31 3/150 2026-04-01 10:44 by 328838485
信息提示
请填处理意见