Recent

Author Topic: how to access windows API functions  (Read 564 times)

freepiston

  • Newbie
  • Posts: 1
how to access windows API functions
« on: August 22, 2022, 10:16:52 am »
After 25 years I thought I would dust off the grey cells and try Lazarus to read a COM port via windows API calls (I used to dabble with Delphi 5).
I'm trying to use 'CreateFile' but the Lazarus compiler cannot find it so I clearly have not the right 'uses' entry.  I am 73 and rather stuck in the assembler/FORTRAN world of the 60s and 70s, so please bear with me!


Jonvy

  • Jr. Member
  • **
  • Posts: 81
Re: how to access windows API functions
« Reply #1 on: August 22, 2022, 10:52:18 am »
You can use LazSerial componment, it's very easy to use,better than using windows API to read COM port.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5051
  • Compiler Developer
Re: how to access windows API functions
« Reply #2 on: August 22, 2022, 01:50:32 pm »
After 25 years I thought I would dust off the grey cells and try Lazarus to read a COM port via windows API calls (I used to dabble with Delphi 5).
I'm trying to use 'CreateFile' but the Lazarus compiler cannot find it so I clearly have not the right 'uses' entry.  I am 73 and rather stuck in the assembler/FORTRAN world of the 60s and 70s, so please bear with me!

Did you add the unit Windows to your uses-clause?

Though if you don't want to dabble with the low level stuff you should indeed follow Jonvy's advice of using some preexisting code like LazSerial or even the Serial unit provided by FPC itself (of which I think LazSerial might be a wrapper).

 

TinyPortal © 2005-2018