1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
//Datamain.h
//----------
#ifndef DATAMAIN_H_
#define DATAMAIN_H_
#pragma once
class Datamain
{
public :
static int Index;
};
#endif
//DataCalcdll.h
//-------------
typedef void (__stdcall *fp_Sub1dllTYPE)(double &,double &,double *,long &,double &,double &,double &,double &,double &,double &,long &,char*,long );
typedef void (__stdcall *fp_Sub2dllTYPE)(double &,double &,double *,long &,double &,double &,double &,double &,double &,double &,long &,char*,long );
fp_Sub1dllTYPE Sub1dll;
fp_Sub2dllTYPE Sub2dll;
//DataFile1.h
//-----------
#ifndef DATAFILE1_H_
#define DATAFILE1_H_
static const long charlength=255;
static const long filepathlength=255;
static const long lengthofreference=3;
static const long errormessagelength=255;
static const long nmax=20;
static const long numparams=72;
static const long maxcoefs=50;
static char Name[charlength*nmax];
static char reference[lengthofreference+1];
static char herr[errormessagelength+1];
static char hf[charlength+1];
#endif
//File1.h
//-----------
#ifndef DATAFILE1_H_
#define DATAFILE1_H__H_
#pragma once
#include <windows.h>
class File1
{
public:
static void Loaddll();
static void Setup(int Num);
};
#endif
//main.cpp
//--------
#include <iostream>
#include <stdio.h>
#include "Datamain.h"
#include "File1.h"
#include "DataFile1.h"
int Datamain::Index;
using namespace std;
int main()
{
Datamain::Index = 3;
File1::Setup(Datamain::Index);
Sub2dll();
}
//File1.cpp
//---------
#include <string>
#include <iostream>
#include <stdio.h>
#include "DataFile1.h"
#include "File1.h"
#include "DataCalcdll.h"
using namespace std;
void File1::Loaddll()
{
// First create a pointer to an instance of the library
// Then have windows load the library.
HINSTANCE dllInstance;
//This looks only in the current directory for dll
dllInstance = LoadLibrary("./Calc.dll");
// Then get pointers into the dll to the actual functions.
Sub1dll = (fp_Sub1dllTYPE) GetProcAddress(dllInstance,"Sub1dll");
Sub2dll = (fp_Sub2dllTYPE) GetProcAddress(dllInstance,"Sub2dll");
}
void File1::Setup(int Num)
{
Sub1dll();
// Sub2dll();
}
|