Trying to port the ConsoleIO unit to Lazarus lazarus / 67-Windows ---------------------------------------------------------------------- Roland57 · 2020-01-29 08:37 Hello! I try to port to Lazarus a Delphi unit named ConsoleIO. The unit doesn't compile. I know that I could use the Process unit for the same task, but I would like to understand why the unit doesn't compile. Here is the unit and the lazarus project (unfinished). The error I get is Quoteconsoleio.pas(278,36) Error: Incompatible type for arg no. 3: Got "
", expected "" Hint: Found declaration: BeginThread(Pointer;QWord;TThreadFunc;Pointer;LongWord;var QWord):QWord; Would you have an idea of the way to solve this issue? Thanks. ---------------------------------------------------------------------- Thaddy · 2020-01-29 08:57 First, the code you included is already mutilated beyond repair by you. So post the original. My guess is that a simple Delphi project containing the unit will be automatically converted using the convert delphi project option. That will also convert ConsoleIO.pas. {Actually that is not a guess...} Anyway, you also need to add {$mode delphi}{$H+} ---------------------------------------------------------------------- wp · 2020-01-29 08:59 When converting from Delphi it is always a good idea to first add the {$MODE DELPHI} directive at the top. Doing this, and removing the @ in Classes.AllocateHWnd(@WndProc) made the unit compile for me; I did no functional tests, though. ---------------------------------------------------------------------- Thaddy · 2020-01-29 09:24 @wp It works, I tested it if that was not already obvious.. ---------------------------------------------------------------------- Roland57 · 2020-01-29 09:30 Thank you for your answers. I will finish my demo project to see if all is OK. By the way, the original package (with its demo project) is included in the composant/archive folder. It's true that I should have tried an automatic conversion starting from the original source. I will try. Regards. Roland ---------------------------------------------------------------------- Thaddy · 2020-01-29 09:34 If not, report back and I show you my minimal changes that work. ---------------------------------------------------------------------- Roland57 · 2020-01-29 09:57 Quote from: Thaddy on January 29, 2020, 10:34:24 amIf not, report back and I show you my minimal changes that work. I finished a first draft of my project but I get a runtime error 211. If you have a working version, I am your friend.  I have to leave. See you later! ---------------------------------------------------------------------- Roland57 · 2020-01-30 06:38 Hello! I restarted from the original source and made an automatic conversion. I removed from the *.lfm the part related to the component, and removed the register procedure in the unit. I added code for component creation in FormCreate. The project compiles but I get an error 211 when I start the application. I don't see what is wrong. Here is the source of the project. ---------------------------------------------------------------------- Roland57 · 2020-01-30 07:14 Maybe there is a relation with what is said in this message? https://forum.lazarus.freepascal.org/index.php/topic,46477.msg332924.h tml#msg332924 ---------------------------------------------------------------------- Thaddy · 2020-01-30 07:20 211 is an abstract error and there are no abstracts in the ConsoleIO unit. The consoleIO unit itself seems correct, but only for 32 bit Windows. You need change the integer cast for the procedure pointer  to PtrInt or PtrUint for it to work on both 32 and 64 bit Windows. I did not examine the rest of the project yet. ---------------------------------------------------------------------- Roland57 · 2020-01-30 07:30 Quote from: Thaddy on January 30, 2020, 08:20:24 am211 is an abstract error and there are no abstracts in the ConsoleIO unit. The consoleIO unit itself seems correct, but only for 32 bit Windows. You need change the integer cast for the procedure pointer  to PtrInt or PtrUint for it to work on both 32 and 64 bit Windows. I did not examine the rest of the project yet. Thank you for your message. I already did that. It seems that the problem comes from AllocateHWnd, and it seems that a solution is given here: https://forum.lazarus.freepascal.org/index.php/topic,36449.msg243056.h tml#msg243056 Now I can start the application without error. ---------------------------------------------------------------------- Roland57 · 2020-01-30 07:38 Same solution indicated here: https://forum.lazarus.freepascal.org/index.php/topic,41951.msg292129.h tml#msg292129 ---------------------------------------------------------------------- Roland57 · 2020-01-30 18:36 Here is the corrected version of the unit, with a demo project.