24小时热门版块排行榜    

查看: 2051  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 2026国自然放榜时间 +3 布布和一二 2026-08-08 3/150 2026-08-08 18:15 by Lightingo
[论文投稿] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 qTvzQBRAHjCi 2026-08-07 4/200 2026-08-08 16:47 by oEVWOejN9taj
[考博] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 Vi50GxzrFcSG 2026-08-07 4/200 2026-08-08 16:27 by oEVWOejN9taj
[基金申请] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 Vi50GxzrFcSG 2026-08-07 4/200 2026-08-08 16:19 by oEVWOejN9taj
[论文投稿] 十年后又回来了,论文投稿求助 +5 哈哈114477 2026-08-01 5/250 2026-08-08 15:14 by 仁砚薪传
[论文投稿] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 Vi50GxzrFcSG 2026-08-07 6/300 2026-08-08 15:07 by oEVWOejN9taj
[论文投稿] 售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急 +3 WQyTGMbfH7Cx 2026-08-07 4/200 2026-08-08 15:02 by oEVWOejN9taj
[硕博家园] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +4 HEQlVqMTIA7d 2026-08-07 6/300 2026-08-08 14:47 by oEVWOejN9taj
[博后之家] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +3 HEQlVqMTIA7d 2026-08-07 6/300 2026-08-08 14:42 by oEVWOejN9taj
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 HEQlVqMTIA7d 2026-08-07 6/300 2026-08-08 14:39 by oEVWOejN9taj
[教师之家] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +4 HEQlVqMTIA7d 2026-08-07 5/250 2026-08-08 14:27 by oEVWOejN9taj
[基金申请] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +4 KXLV3nuBVBY7 2026-08-07 5/250 2026-08-08 14:07 by oEVWOejN9taj
[基金申请] 关于代码变化问题,想知道的进来 +11 且听虎啸 2026-08-07 14/700 2026-08-08 12:50 by 布布和一二
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 影响面上的因素 +8 布布和一二 2026-08-05 11/550 2026-08-06 10:41 by 宝贝虫子
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
[基金申请] 有没有H口的?有收到消息的吗? +3 超级海虾 2026-08-04 3/150 2026-08-04 17:26 by 学教育滴
[基金申请] 面上提前没消息,有中的吗 +14 archvillain 2026-08-02 18/900 2026-08-04 14:42 by archvillain
信息提示
请填处理意见