Search the Community
Showing results for tags 'dll'.
Found 13 results
-
I have created a DLL with one exported function using the latest version of Delphi (12.1). The function takes one parameter: a record type variable. library MyDLL; uses System, SysUtils; type TMyRecord = record MyString: AnsiString; MyInteger: Integer; end; function FillRecord(var Rec: TMyRecord): Boolean; stdcall; export; begin Rec.MyString := 'Hello from Delphi'; Rec.MyInteger := 42; Result := True; end; exports FillRecord; begin end. In my C++ Builder 6.0 application, I have declared the following: struct TMyRecord { char *MyString; int MyInteger; }; extern "C" __declspec(dllimport) bool __stdcall FillRecord(TMyRecord *Rec); When calling the 'FillRecord' function from my C++ Builder application, I do not get the expected results: TMyRecord iMyRec; Memo1->Lines->Clear(); Memo1->Lines->Add(Format("Address: %p", ARRAYOFCONST((&iMyRec)))); if (FillRecord(&iMyRec)) { String iData = iMyRec.MyString; Memo1->Lines->Add("iMyRec.MyString: " + iData); int iNumber = iMyRec.MyInteger; Memo1->Lines->Add("iMyRec.MyInteger: " + IntToStr(iNumber)); } else { Memo1->Lines->Add("Error calling FillRecord"); } I am expecting: iMyRec.MyString: Hello from Delphi iMyRec.MyInteger: 42 But I am getting: iMyRec.MyString: H iMyRec.MyInteger: 42 I am drawing a blank when trying to figure out what I am doing wrong. Any inputs/suggestions to solve my issue would be greatly appreciated. Thank you
- 3 replies
-
- delphi
- c++ builder
-
(and 3 more)
Tagged with:
-
DLL usage difference between Delphi 11.3 and Delphi 10.4
Ron Howard posted a topic in RTL and Delphi Object Pascal
Struggling to identify what the difference is in Delphi 10.4 and Delphi 11.3 in regards to the use of a DLL function. I have some legacy code that uses a security library. Works fine when compiled with Delphi 10.4 both for 32-bit and 64-bit. In Delphi 11.3 it works fine for 32-bit, but not for 64-bit. No changes to the code, nor project settings. Code: Interface Function pp_lfopen (filename: PAnsiChar; lfflags: LongInt; lftype: LongInt; password: PAnsiChar; handle: PLongInt): LongInt; stdcall; Implementation const {$IFDEF WIN32} KeyLibModuleName = 'KEYLIB32.dll'; {$ELSEIF Defined(WIN64)} KeyLibModuleName = 'KEYLIB64.dll'; {$ENDIF} Function pp_lfopen; external KeyLibModuleName; Usage: var LHandle: Longint; begin Lresult := pp_lfopen(PAnsiChar(FlicFilePath), 0, LF_FILE, PAnsiChar(FlicPassword), @Lhandle); if Lresult = PP_SUCCESS then begin // additional DLL calls, which fail due to the invalid handle end; end; The path and password are correct and valid text constants. My analysis so far has shown that the Lhandle returned is not valid, even though the function result indicates success. Just recently switched over to Delphi 11.3, but I cannot pinpoint the cause so far. Anyone with knowledge about the differences in 11.3 compared to 10.4 that could explain this? Or ideas to find the cause? -
I have a question in regards to the new SKI support. When I 'enabled' SKIA in the IDE there was no noticeable change to the project or settings that I found. I could 'disable' it on the IDE as well. What I finally noticed was in the executable folder there was now a sk4d.dll. If I move the file out of that directory the application still ran. (I was expecting some sort of load error (?)).. My question- so even though the application is self contained otherwise - the 32 bit or 64 bit sk4d.dll file needs now to be deployed also? Thanks in advance
-
Why are the .PAS files not showing in PROJECT Pane (and Version Control)
Cirrus22 posted a topic in VCL
I moved from D10.4.2 (IIRC) to the D11.3 CE. I have already posted about issues with File Version, but here's something that may be correct or not. This is a DLL. When I view the Project pane in the IDE, it only shows the project, it does not show the related (or any other) *.pas files. There seems no way I can make it show them. For the record, the PAS file is uDbXConnect.pas: And further, in GIT version control, it only shows the *.dproj, I cannot, within the IDE at least, add any other files (just as I cannot in IDE>Project. Previously I was using subversion (yes, I know not as good, but at least it worked and was simple). I cannot get subversion to work with 11.3 - that's another issue. Here's what I see in GIT Commit, only the dproj file. Note I can view all of the non-versioned files, but I cannot seem to get them to add to the GIT version control/repository. Am I supposed to be doing things with GIT outside the IDE, that kinda makes no sense if we are assuming this is Version Control with IDE integration. As noted, with subversion previously, it was relatively easy, this just doesn't seem to work (as I expected it to). Does anyone have a handle on what I should do to set this up correctly or can point me to appropriate documentation? Thanks...... -
Can I use managed C# DLL in unmanaged Delphi application ?
AndrewHoward posted a topic in General Help
Can I use managed C# DLL in unmanaged Delphi application ? Thanks -
My app consists of a main VCL-based app and a number of plugins implemented as .bpl packages. I'd like to incorporate Python using P4D, but I'm having problems. My first attempts work fine in the main app, but I cannot get the bpl's to work. In effect, my main app loads the Python .dll, runs some Python code, then loads the .bpl packages; these packages, however, can't seem to access the Python .dll, as GetPythonEngine thinks the global variable gPythonEngine is nil. My guess is that this is explained because gPythonEngine belongs to the app, and is not visible in the .bpl. I tried loading the Python .dll in both the app and the .bpl, but that doesn't seem to work in a different way when I try to load a Python module. I first try to add a folder to the Python path using the following, abd I get a EPyAttributeError with the message "module 'sys' has no attribute 'Path'. if not Boolean(SysModule.Path.Contains(folder)) then begin SysModule.Path.Insert(0, folder); end; My guess is that I am not going to be able to use P4D from both the main app and several .bpl (i.e. DLLs) simultaneously. It seems there are a few reasons why, but I'm not certain if I understand exactly the limitations. 1. It appears that the Python DLL really only supports one instantiation per process. It isn't entirely clear if this is a DLL restriction or due to the Python DLL's design itself. Is this true absolutely? 2. Even if I could "share" the Python environment created when loading the DLL, I'm likely to run into problems because some functions use that global; for example, the SysModule functions don't provide a means to provide the pointer to the Python environment, but rather access that global directly. Is this correct? 3. Because I use certain .bpls as plug-ins, I can't readily get rid of the .bpls and go to a monolithic architecture, so it seems my only option might be to write another .bpl that encapsulates all the P4D/Python.dll stuff in it, and provides routines for other .bpls and the main app to give access to the Python environment that way. Other than being a bit more work, this does have some nice characteristics, such as hiding all the P4D details in one place, and it formalizes the notion of the Python environment (e.g. when it starts, who "owns" it, and its global nature). This could really work well for my application, as its use of Python is, by domain design, serialized naturally, and benefits from the persistent state from call to call. But before I go down that road, does this even make sense?
-
Hi, all, I've created a DLL, where resourcestrings are used. Everything works in Debug target, but it doesn't work when I compile the project for Release target. I've checked compiler and linker options and can't find anything suspicious. The string is a junk when I run my DLL project (with a host app) in Release target What is it and is there any solution? Now I simply changed resourcestring to const declaration, but it looks a bit ugly. Lokks like the probkem is in HINST variable or something like that Yet I could understand it, but why it doesn't work in Release target only? I use XE7 x64 complation. Thank you in advance.
-
Hi, In order to call a Delphi DLL in a Fortran program (compiler: Intel Fortran compiler "ifort"), ifort needs the import library of the DLL. How can I create an "import library" from my 64-Bit Delphi DLL or from my project?
- 2 replies
-
- dll
- import library
-
(and 1 more)
Tagged with:
-
Hi, I have an application which loads & uses an unmanaged dll. All I have to do is drop the dll it in a specific folder. Can I use a .Net dll instead ? (I know the .Net dll needs to expose the same functions which are in the unmanaged dll) Can an unmanaged & managed DLLs be used interchangeably ? Thanks
-
Hi, friends Im with a little problem. Im trying to create a delphi Dll with a form in RAD Studio, but i don't know how to make it load with DllMain. I want to inject this Dll in a third-party process at runtime after. I created the Dll project with the form without problems, but i can't find nothing good related to "how to load it with DllMain", or at least the tutorials/things i found doesn't helped me (or i'm just dumb ). Can someone help me? Give me some hint or a site/video where i can learn it? Thanks for your time guys! =)
-
Using dlls inside datasnap webbroker application
MarianSaad posted a topic in Network, Cloud and Web
Hi, I created an API using datasnap webbroker in delphi 10.3 I am calling an entry point inside a dll that is responsible for creating reports. It works fine for single call. I did a simple test by calling my API two times simultaneously but the dll crashed. How can I get the dll handle simultaneous requests? Thanks! -
Hallo to all, since 10.4 (and 10.4.1) debugging c++ DLL for x64 Windows S.O. is impossible (for me of course). ALL THE PROJECTS ARE COMPILED FOR X64. If I launch standard debug from Delphi project, the DLL source code (made in c++) is ignored and no breakpoints are used in the DLL. If I launch LLDB debug from c++ DLL (setting the correct host of course), an error like this is generated and the app doesn't start. If you launch the app with or without Delphi debugger all is working. Same situation with remote debugger (via "old style debugger" or paserver). Before LLVM all is working and i can debug DLL c++ code. I miss something or do something wrong ? Attached is a very simple project group to test. Thanks for your attention. Test.zip
-
Can I use dynamically linked MPL 2.0 dll library for commercial purposes?
at3s posted a topic in General Help
dll is a wrapper of MPL 2.0 C++ library. Can I use this dll in my commercial project (an executable dynamically calls a function of dll)? Will users be able to request sources of this dll only or all my whole project?