H
HotIndigo
Guest
I'm very new to C++ (I write in VB and PERL) but need to create a .dll using c++. The function needs to receive a text array and return a text array. I have written a .h and .cpp file but when I try to compile them, I get an "Error C2065 'GetTblTxt': undeclared identifier" message. I have tried all sorts of suggestions to correct this but have come with a blank. I have attached both files - maybe someone can point me in the right direction.
GetStrArry.h
#pragma once
#include <Windows.h>
#define TableFunctions
#include <string>
#include <vector>
using namespace std;
using std::string;
#define WINAPI __stdcall
//#ifdef MYLIBRARY_EXPORTS
#define MYLIBRARY_API __declspec(dllexport)
//#else
//#define MYLIBRARY_API __declspec(dllimport)
//#endif
namespace Libfuncs
{
class GetTable
{
private:
static void Libfuncs::GetTable::Get_Table1(double P1, double P2, int P3, double &TblVal, int &TblUnits);
private:
static void Libfuncs::GetTable::Get_Table2(double P1, double P2, int P3, double &TblVal, int &TblUnits);
public:
static MYLIBRARY_API std::vector<wstring> Libfuncs::GetTable::GetTblTxt(std::vector<wstring>);
};
BOOL WINAPI DllMain(HINSTANCE hinstDll,
DWORD dwReason,
LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)GetTblTxt, 0, 0, 0);
}
return TRUE;
};
};
GetStrArry.cpp
#include "GetStrArry.h"
#include <string>
using namespace std;
using std::string;
using std::wstring;
namespace Libfuncs
{
static void Get_Table1(double Parm1, double Parm2, int Parm3, double &TblVal, int &TblUnits)
{
// This is just Test Code to check functionality.
TblVal = 0.00045;
TblUnits = 5;
};
static void Get_Table2(double Parm1, double Parm2, int Parm3, double &TblVal, int &TblUnits)
{
// This is just Test Code to check functionality.
TblVal = 1.25;
TblUnits = 6;
};
static std::vector<wstring> GetTblTxt(std::vector<wstring> InputArray)
{
//InputArray Structure:
//(0) = Parameter 1 as Text String.
//(1) = Parameter 2 as Text String.
//(2) = Parameter 3 as Text String.
//(3) = Table Selector as Text String.
//OutputArray Structure:
//(0) = Table Value as Text String.
//(1) = Table Units as Text String.
double Param1 = stof(InputArray[0]);
double Param2 = stof(InputArray[1]);
int Param3 = stoi(InputArray[2]);
int TblSelector = stoi(InputArray[3]);
double TblVal = 0;
int TblUnits = 0;
constexpr int Search1 = 0;
constexpr int Search2 = 1;
std::vector<std::wstring> OutPutString(2);
switch (TblSelector)
{
case Search1:
Get_Table1(Param1, Param2, Param3, TblVal, TblUnits);
break;
case Search2:
Get_Table2(Param1, Param2, Param3, TblVal, TblUnits);
break;
};
OutPutString[0] = to_wstring(TblVal);
OutPutString[1] = to_wstring(TblUnits);
return OutPutString;
};
};
I hope this is enough information.
All the best,
HotBlue.
Continue reading...
GetStrArry.h
#pragma once
#include <Windows.h>
#define TableFunctions
#include <string>
#include <vector>
using namespace std;
using std::string;
#define WINAPI __stdcall
//#ifdef MYLIBRARY_EXPORTS
#define MYLIBRARY_API __declspec(dllexport)
//#else
//#define MYLIBRARY_API __declspec(dllimport)
//#endif
namespace Libfuncs
{
class GetTable
{
private:
static void Libfuncs::GetTable::Get_Table1(double P1, double P2, int P3, double &TblVal, int &TblUnits);
private:
static void Libfuncs::GetTable::Get_Table2(double P1, double P2, int P3, double &TblVal, int &TblUnits);
public:
static MYLIBRARY_API std::vector<wstring> Libfuncs::GetTable::GetTblTxt(std::vector<wstring>);
};
BOOL WINAPI DllMain(HINSTANCE hinstDll,
DWORD dwReason,
LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)GetTblTxt, 0, 0, 0);
}
return TRUE;
};
};
GetStrArry.cpp
#include "GetStrArry.h"
#include <string>
using namespace std;
using std::string;
using std::wstring;
namespace Libfuncs
{
static void Get_Table1(double Parm1, double Parm2, int Parm3, double &TblVal, int &TblUnits)
{
// This is just Test Code to check functionality.
TblVal = 0.00045;
TblUnits = 5;
};
static void Get_Table2(double Parm1, double Parm2, int Parm3, double &TblVal, int &TblUnits)
{
// This is just Test Code to check functionality.
TblVal = 1.25;
TblUnits = 6;
};
static std::vector<wstring> GetTblTxt(std::vector<wstring> InputArray)
{
//InputArray Structure:
//(0) = Parameter 1 as Text String.
//(1) = Parameter 2 as Text String.
//(2) = Parameter 3 as Text String.
//(3) = Table Selector as Text String.
//OutputArray Structure:
//(0) = Table Value as Text String.
//(1) = Table Units as Text String.
double Param1 = stof(InputArray[0]);
double Param2 = stof(InputArray[1]);
int Param3 = stoi(InputArray[2]);
int TblSelector = stoi(InputArray[3]);
double TblVal = 0;
int TblUnits = 0;
constexpr int Search1 = 0;
constexpr int Search2 = 1;
std::vector<std::wstring> OutPutString(2);
switch (TblSelector)
{
case Search1:
Get_Table1(Param1, Param2, Param3, TblVal, TblUnits);
break;
case Search2:
Get_Table2(Param1, Param2, Param3, TblVal, TblUnits);
break;
};
OutPutString[0] = to_wstring(TblVal);
OutPutString[1] = to_wstring(TblUnits);
return OutPutString;
};
};
I hope this is enough information.
All the best,
HotBlue.
Continue reading...