Labview类型到c#的转换

本文关键字:转换 类型 Labview | 更新日期: 2023-09-27 18:10:46

我只是希望有人可能有一个答案。在与Labview和Device公司交涉无果之后,我最终在这里发帖。

我目前正在制作一个控制设备的应用程序,它提供了Labview编译的DLL。dll编译时缺少一些必要的Labview函数。所以我必须使用Labview运行时引擎直接调用函数。Labview网站回复我,我必须直接与设备公司打交道,他们没有解决方案给我。

有一个labview函数叫做FCreate (labview Manager function),它被定义为:

MgErr FCreate(File* fdp, Path path, int32 permissions, int32 openMode, int32 denyMode, PStr group);

如果这个函数创建了文件,结果文件描述符存储在fdp引用的地址中。

还有一个函数叫做FNewRefNum:

FNewRefNum(Path path, File fd, LVRefNum* refNumPtr)

此函数为文件描述符为fd的打开文件创建一个新的文件refnum。

refNumPtr是我必须创建并传递给dll的那个,它没有上面的函数编译。

我需要知道c#中这两个labview函数的确切类型转换。或者至少转换为c++,然后我可以将它们转换为c#。

用Labview运行时引擎测试了函数调用,引擎似乎可以识别。当前我遇到的错误是"AccessViolationException was unhandled"

ErroMessage: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

提前感谢任何试图帮助的人。

Labview类型到c#的转换

您需要查看extcode.h以查看各种类型的定义。我在网上找到了一个实例:

typedef int32   MgErr; 
#define LV_PRIVATE(T)   typedef struct T##_t { void *p; } *T 
/** @struct File 
Opaque type used by the file manager. See filemgr.cpp */ 
LV_PRIVATE(File); 
/** @struct Path 
Opaque type used by the path manager. See pathmgr.cpp 
declared here for use in constant table */ 
typedef struct PATHREF PathRef;
typedef PathRef*        Path;
typedef uChar       *PStr, **PStrHandle, *CStr; 
/** MagicCookie 
Opaque type used by the cookie manager. */ 
typedef uInt32 MagicCookie; 
typedef MagicCookie LVRefNum; 

总的来说,你所有的类型要么是int要么是IntPtr:

MgErr: int
File: IntPtr
Path: IntPtr
int32: int
PStr: IntPtr
LVRefNum: int

你可以这样声明函数:

int FCreate(IntPtr* fdp, IntPtr path, int permissions,
            int openMode, int denyMode, IntPtr group);
int FNewRefNum(IntPtr path, IntPtr fd, int* refNumPtr);