.h file conent:
extern "C" __declspec(dllexport) double WINAPI P452Calc(int, int *);
.cpp file content:
double WINAPI P452Calc(int i, int * ii) {
return i;
}
VBA code:
Declare PtrSafe Function P452Calc Lib "P452Lib.dll" (ByVal i As Integer, ByRef ii As Integer) As Double
Public Function Test()
Dim i As Integer
Dim ii As Integer
i = 33
ii = 2
Test = P452Calc(i, ii)
End Function
Exception thrown at 0x00007FF9833F917F (kernel32.dll) in EXCEL.EXE: 0xC0000005: Access violation reading location 0x0000000000000021. (21h == 33 i variable value)
I can not figure out what exactly wrong.