Posted by on in Blogs
You may also want to call your DLL function directly from Delphi. No more comments, just a sample code: program A; {$APPTYPE CONSOLE} uses Windows, System.SysUtils; var   res : Integer;   dll_handle: THandle;   MyFunction: function(param: integer): Integer stdcall; begin   res := 0;   dll_handle := LoadLibrary('My.DLL');   if (0 <> dll_handle)   then begin     @MyFunction := GetProcAddress(dll_handle, '_DllFunction');     if (NIL <> @MyFunction)     then begin       res := MyFunction(1);     end;     FreeLibrary(dll_handle);   end;   WriteLn(res); end. As you can see this is a same C++ code but re-written on Embarcadero XE3 Delphi. And what is DLL code? I...

Posted by on in Blogs
DLL could be loaded implicitly or explicitly. Another way is Static Linkage that allows placing all required functions to your program to avoid DLLs usage at all, but it is out of this post. Implicit DLL loading is having your program to load DLL before main() called. You specify DLL's library name already when linking a program; it will work with that exact version of DLL and will not even start without. Implicit load pros/contras: + Simple + Program will either start or not - Longer loading - Depends on exact DLL version Explicit DLL loading allows loading DLL when only needed, like a plug-in. After DLL loaded you call its functions by known names and then unload. Explicit load pro...

Posted by on in Blogs
Typical DLL has an entry point. This is a function with a specific name which linker aware of. When DLL is loaded or unloaded this function is called; that helps to init DLL data or release resources. If you need this you should implement such a function. On RAD-built DLL load/unload, DLL itself automatically calls first matched function from this list: DllEntryPoint(), DllMain(),and last _libmain(). If more than one co-exists, others will be optimized-out, i.e. only best match will reside in DLL and it will be called. You should not call such function directly from program that loads DLL, hence they are not __declspec(dllexport) marked. DllMain() is a known Windows DLL entry point whi...

Posted by on in Blogs
I will dig to details assuming you have already read this article: http://docwiki.embarcadero.com/RADStudio/en/Creating_Packages_and_DLLs In order to create a simple DLL in Embarcadero RAD XE3 create a new DLL project: File|New|Other…|C++BuilderProjects|Dynamic-linkLibrary Set it: C++ = On, Target Framework = None, Multi Threaded = On You will already have some code like: extern "C" int _libmain(unsigned long reason) { return 1; } Save and build; open your build folder like: C:\Users\YourName\Documents\RAD Studio\Projects\Win32\Debug Most important files there are: Project1.dll (DLL itself), Project1.lib (library file), Project1.map, and Project1.tds. You ...

Posted by on in Blogs
I work for Embarcadero as QA and my primary area is testing Debugger, mostly its low-to-mid levels. Hence, I keep my fingers on RAD features. Here I would like to share not very straight-forward things that could save some time to SW developers who use Embarcadero RAD Studio XE3....
  • Page :
  • 1