Hey Leute
Ich hab mir mal das MSN Tutorial zum Erstellen von dlls mit VC++ zu Gemüte geführt, doch wenn ich die erstellte dll in AutoIt ancalle dann kommt immer 0 raus und nen array wird auch nich zurückgegeben:S
Ich hab mal VC++ Projektmappe, die dll und das AutoIt skript beigefügt, hier nochmal alles als code:
Spoiler anzeigen
[autoit]
$dll = DllOpen(@ScriptDir&"MathFuncsDLL.dll")
$result = DllCall($dll,"int","Add","double",12,"double",8)
MsgBox(0,"",$result[0])
HeaderCode
Spoiler anzeigen
Code
// MathFuncsDll.hnamespace MathFuncs
{class MyMathFuncs
{public:
// Returns a + bstatic __declspec(dllexport) double Add(double a, double b);
// Returns a - bstatic __declspec(dllexport) double Subtract(double a, double b);
// Returns a * bstatic __declspec(dllexport) double Multiply(double a, double b);
// Returns a / b
// Throws DivideByZeroException if b is 0static __declspec(dllexport) double Divide(double a, double b);
};
}
CPP Datei Code oder wie man das nennt
Spoiler anzeigen
C
// MathFuncsDll.cpp
// compile with: /EHsc /LD
#include "MathFuncsDll.h"
#include <stdexcept>
using namespace std;namespace MathFuncs
{double MyMathFuncs::Add(double a, double b)
{return a + b;
}double MyMathFuncs::Subtract(double a, double b)
{return a - b;
}double MyMathFuncs::Multiply(double a, double b)
{return a * b;
}double MyMathFuncs::Divide(double a, double b)
{if (b == 0)
{throw new invalid_argument("b cannot be zero!");
}return a / b;
}
}
Alles anzeigen