I try to import functions from a NetWeaver.dll in c++.
One of the declarations is:
DECL_EXP RFC_CONNECTION_HANDLE SAP_API RfcOpenConnection(RFC_CONNECTION_PARAMETER const * connectionParams, unsigned paramCount, RFC_ERROR_INFO* errorInfo);
My first attempt was:
DECL_EXP RFC_CONNECTION_HANDLE SAP_API (*RfcOpenConnectionImp) (RFC_CONNECTION_PARAMETER const*, unsigned, RFC_ERROR_INFO *) = (DECL_EXP RFC_CONNECTION_HANDLE SAP_API(*) (RFC_CONNECTION_PARAMETER const*, unsigned, RFC_ERROR_INFO*)) GetProcAddress(hinstLib, "RfcOpenConnection");
but following error occured:
"Auf eine Aufrufkonvention darf kein geschachtelter Deklarator folgen." Means something like: "After a calling convention a nested declarator is not allowed."
So I tried some variations until the compiler was satisfied with:
RFC_CONNECTION_HANDLE (*RfcOpenConnectionImp) (RFC_CONNECTION_PARAMETER const*, unsigned, RFC_ERROR_INFO *) = (RFC_CONNECTION_HANDLE (*) (RFC_CONNECTION_PARAMETER const*, unsigned, RFC_ERROR_INFO*)) GetProcAddress(hinstLib, "RfcOpenConnection");
so it compilled an throwed a error during runtime:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Well, not really surprising...
But how do I import this kind of function the correctly?
Thanks for help!