[fpc-pascal] opening a serial port in a dll called from dot net fails

Elmar Haneke elmar at haneke.de
Mon Mar 11 11:38:42 CET 2024


Presumably the problem is caused by calling your function from a 
different thread.

Perhaps it is a solution to put the SerOpen in a thread created by FPC 
and signal that thread from your dot-net-called function.

Am 09.03.24 um 16:24 schrieb Luca Olivetti via fpc-pascal:
> I'm writing a dll that is used by a dot net application (32bits).
>
> If I call SerOpen in the initialization section of the dll there is no 
> problem, but if I call it from one of the exported functions it gives 
> me an access denied (GetLastError gives me a 5), and I really need to 
> call it from a function (due to some quirks in the calling program 
> which is not under my control).
>
> A search in the usual places tells me that in dot net opening a serial 
> port with CreateFile (which is what SerOpen does) is forbidden, that 
> you should use the SerialPort class (which I don't think I can do from 
> my dll written in freepascal).
>
> Is there any way to solve my problem?
>
> Bye
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20240311/d12b2ada/attachment.htm>


More information about the fpc-pascal mailing list