Hi everyone,
I call successfully a dll function written in c++ from a macro created in EXCEL VBA.
the function is called with a Declare statement:
Private Declare PtrSafe Function FourierSerieCoeffs Lib "D:\OutBin\ISLib.dll" (ByVal T As Double, ByVal n As Long, ByVal nEq As Long, ByRef x As Double, ByRef fx As Double, ByRef outC As Double) As Long
After the first execution of the macro it is impossible for me to rebuild the dll because it seems that Excel is still using it.
The only way to rebuild the dll project with the excel file opened is to add at the end of the macro these lines:
hMod = GetModuleHandle("ISLib.dll")
Do Until FreeLibrary(hMod) = 0
Loop
with these lines i can compile the c++ project but if I execute again the macro excel crashes.
Any suggestion to release the dll without make excel crash in the next executions?
Thanks
What I have tried:
I tried calling the library again with LoadLibrary at the beginning of the macro but it doesn't work.