Is there a way to dynamically load DLL File and execute an exported function from that DLL at runtime ?
Please Anyone share me a Sample Code if it's Possible...
- Founder/Site Admin
- Posts: 2912
- Joined: 24 Feb 2017, 09:12
- Location: Gouda, The Netherlands
First, it depends on what you mean by "Load DLL and execute function at runtime".
When you know the DLL and function at compile time, you can declare the dll and function in the External Functions section and call it.
In fact, TD will load the DLL at runtime at the moment you call a function from it.
You can declare the function using the exact name or using the ordinal number.
When you know the DLL and function at compile time (as in scenario 1) but you are not sure the DLL is present at runtime or you are not sure the function is present in the DLL:
You can check if the DLL is on the system and if the function is present in the DLL prior calling it.
See this article how to do this:
https://wiki.tdcommunity.net/index.php/ ... at_runtime
When you do not know the DLL name and functions at compile time and runtime. So you want to use it dynamically at runtime.
So, as can be seen in scenario 2, we can detect the presence of the DLL and function at runtime.
In the end you can get a pointer to the function in the DLL.
But there is no way we can call the function straight from TD. TD does not support calling function pointers.
IMHO in this case you need to create a c++ wrapper which does it for you, but it is still not really fully dynamic.
The issues for this are explained here:
https://www.codeproject.com/Articles/91 ... lection-in
So it really depends what you need. Which scenario?
Who is online
Users browsing this forum: [Ccbot] and 0 guests