24小时热门版块排行榜    

查看: 1775  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 271求调剂 +11 生如夏花… 2026-03-11 13/650 2026-03-17 09:02 by 雾散后相遇lc
[考研] 274求调剂 +5 时间点 2026-03-13 5/250 2026-03-17 07:34 by 热情沙漠
[考研] 11408 一志愿西电,277分求调剂 +3 zhouzhen654 2026-03-16 3/150 2026-03-17 07:03 by laoshidan
[考研] 0854控制工程 359求调剂 可跨专业 +3 626776879 2026-03-14 9/450 2026-03-16 17:42 by 626776879
[考研] 梁成伟老师课题组欢迎你的加入 +8 一鸭鸭哟 2026-03-14 9/450 2026-03-16 17:35 by 沐霖12138
[考研] 311求调剂 +5 26研0 2026-03-15 5/250 2026-03-16 16:21 by a不易
[考研] 283求调剂 +10 小楼。 2026-03-12 14/700 2026-03-16 16:08 by 13811244083
[考研] 312求调剂 +3 陌宸希 2026-03-16 4/200 2026-03-16 15:06 by peike
[考研] 求老师收留调剂 +4 jiang姜66 2026-03-14 5/250 2026-03-15 20:11 by Winj1e
[考研] 材料与化工 323 英一+数二+物化,一志愿:哈工大 本人本科双一流 +4 自由的_飞翔 2026-03-13 5/250 2026-03-14 19:39 by hmn_wj
[考研] 297求调剂 +4 学海漂泊 2026-03-13 4/200 2026-03-14 11:51 by 热情沙漠
[考研] 2026考研调剂+本科延边大学+山东大学+生物化学与分子生物学+有项目经验 +3 ccdsscjy 2026-03-10 3/150 2026-03-14 00:12 by JourneyLucky
[考研] 材料工程,326分,求调剂 +6 KRSLSR 2026-03-10 6/300 2026-03-13 23:47 by JourneyLucky
[考研] 341求调剂 +4 番茄头--- 2026-03-10 4/200 2026-03-13 23:12 by JourneyLucky
[考研] 333求调剂 +3 球球古力 2026-03-11 3/150 2026-03-13 21:27 by JourneyLucky
[考研] 329求调剂 +3 miaodesi 2026-03-12 4/200 2026-03-13 20:53 by 18595523086
[考研] 311求调剂 +3 冬十三 2026-03-13 3/150 2026-03-13 20:41 by JourneyLucky
[考研] 290求调剂 +3 ADT 2026-03-13 3/150 2026-03-13 10:19 by peike
[考研] 收调剂 +7 调剂的考研学生 2026-03-10 7/350 2026-03-10 17:57 by 麦茶汤圆
[考研] 一志愿:武汉理工,材料工程,英二数二 总分314 +3 2202020125 2026-03-10 4/200 2026-03-10 13:54 by xiongyaxuan
信息提示
请填处理意见