Hi,
I want to convert the C code, that reads a DLL generated from Matlab/Simulink:
#include <windows.h>
void main() {
// types
void (*mdl_initialize)(void); // function
double* mdl_G; // value
// Dll load
void* dll = LoadLibrary("./teste_win64.dll");
// GetProcAddress
mdl_initialize = (void(*)(void))GetProcAddress(dll , "initialize");
mdl_G = ((double*)GetProcAddress(dll, "G"));
// Run initialize and capture the G value
mdl_initialize();
printf("G = %.2f",*mdl_G);
}
to Golang.
I just tried this tip:
func main() {
dll, _ := syscall.LoadDLL("./teste_win64.dll")
mdl_init, _ := syscall.GetProcAddress(dll.Handle, "initialize")
mdl_G, _ := syscall.GetProcAddress(dll.Handle, "G")
real_init := (*func())(unsafe.Pointer(&mdl_G))
real_G := (*float64)(unsafe.Pointer(&mdl_G))
real_init()
log.Print(*real_G)
}
But no success. Any tip?