Answer the question
In order to leave comments, you need to log in
How to call a delphi function from C++ that doesn't have stdcall specified?
Tried using __fastcall but still doesn't work.
I have a dll, the calls of which do not need to be changed, but it must be called from the program (I will not give an example of a function, because now this is not a bit about that). I can't understand why this test case doesn't work:
function TestRunMethod2(x1 :Integer):Integer; export;
begin
Result := x1;
end;
C++ code:
HMODULE mod = LoadLibraryW(L"Project12.dll");
typedef int (__fastcall *f_funci)(int x1);
f_funci funci = (f_funci)GetProcAddress(mod, "TestRunMethod2");
register is fastcall, isn't it?
It does not work in this case - instead of the result it returns 0. If you declare it as stdcall both there and there, everything is fine. But I will need to call a function that is not declared as stdcall.
Answer the question
In order to leave comments, you need to log in
The calling convention types are register, pascal, cdecl, stdcall, and safecall.
By default for delphi - register
And that means "does not work". Here you can assume many options:
1. The library does not export the function.
2. Export only by index
3. Pre-initialization of the library is required by calling another function
, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question