并口 read/write C# Windows 10

Paralel port read/write C# Windows 10

我希望能够从 C# 读取和写入 LPT 端口。

尝试导入 inpoutx64.dll 和 inpout32.dll,以使用它们读取和写入 LPT 端口。但是我在添加引用时收到以下错误消息...

A reference to 'C:\Users\User\Documents\inpoutx64.dll' could not be added. Please ensure that the file is accessible, and that it is a valid assembly or COM component.

windows 10 是否有任何其他 DLLer,或者我可以在 Windows SDK 中使用什么来与 LCP 端口通信...?

我使用 Windows 10 64 位和 .NET 4.5。

由于 inpoutx64.dllinpout32.dll 不是有效的程序集或 COM 组件,您无法使用项目引用导入它们。

您需要在代码中导入dll的功能,如

[DllImport("inpout32.dll", EntryPoint = "Inp32")]
private static extern int Input(int adress);

[DllImport("inpout32.dll", EntryPoint = "Out32")]
private static extern void Output(int adress, int value);

您可以在 this article.

找到有关此 导入 的精彩描述和更多信息

请注意,dll 需要与您的可执行文件位于同一文件夹中。通过将 dll 添加到您的项目并将构建操作设置为 复制到输出目录.

,这很容易实现