在C#中使用uDMX API [英] using uDMX API in c#
问题描述
我是C#中的新手,我想使用此uDMX API ,但是当我尝试添加uDMX.dll文件时,出现以下错误:引用无效或不受支持(请参见屏幕截图(德语))
>我还不能添加图片-
I am relative new in c# and I want to use this uDMX API, but when I try to add the uDMX.dll file I get this error: "The reference is not vaild or not supported" (see screenshot (in german)) - I can't add images yet -
还是我做的完全错误?
我没有找到其他uDMX api或.dll文件。
Or am I doing it completely wrong? I did not find another uDMX api or .dll file.
希望为您提供帮助和想法。
Hope for your help and Ideas.
推荐答案
您不能像这样将非托管的win32 dll导入托管的c#应用程序,您需要自己指定方法和参数。
You cant import an unmanaged win32 dll into a managed c# application like that, you need to specify the methods and parameters yourself.
uDMX api公开了这些方法
The uDMX api exposes these methods
bool _stdcall Configure() ;
bool _stdcall Connected() ;
bool _stdcall ChannelSet(long Channel, long Value) ;
bool _stdcall ChannelsSet(long ChannelCnt, long Channel, long* Value) ;
bool _stdcall Info() ;
为了在托管代码中使用它们,您需要提供声明,返回值和参数以.Net
In order to use them in managed code, you need to provide the declaration, return value and parameters to .Net
这是通过将方法标记为外部方法并通知.Net在哪里找到它,使用 DllImport
属性在 System.Runtime.InteropServices
命名空间中找到。
This is done by marking a method as external and informing .Net where to find it, use the DllImport
attribute found in the System.Runtime.InteropServices
namespace.
using System;
using System.Runtime.InteropServices;
class uDMXTest
{
[DllImport("uDMX.dll")]
public static extern bool Configure();
public static void Main()
{
bool result;
result = Configure();
Console.WriteLine(result);
}
}
有关如何提供Configure方法声明的示例,以及如何使用它。
您可以用相同的方式声明uDMX.dll中的其他方法-请注意,您可能需要在DllImport属性中提供uDMX.dll的完整路径
Example on howto provide a declaration of the Configure method, and howto use it. You can declare the other methods in uDMX.dll the same way - note you may need to give the full path to uDMX.dll in the DllImport attribute
这篇关于在C#中使用uDMX API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!