I am just hoping for somebody out there who might have an answer. I am posting here eventually after fruitless dealing with Labview and the Device company.
开发者_JAVA百科I am currently making an application to control a device, which is provided with Labview compiled DLL. The dll is compiled with missing some necessary Labview functions not included. So I have to call functions directly using Labview Run Time Engine. The Labview website replied me that I have to deal directly with the device company, which has no solution for me.
There is a labview function called FCreate (Labview Manager Function) which is defined as:
MgErr FCreate(File* fdp, Path path, int32 permissions, int32 openMode, int32 denyMode, PStr group);
If this function creates the file, the resulting file descriptor is stored in the address referred to by fdp.
And the there is another function called FNewRefNum:
FNewRefNum(Path path, File fd, LVRefNum* refNumPtr)
This function creates a new file refnum for an open file with file descriptor fd.
The refNumPtr is the one that I have to create and pass in to the dll, which doesn't have above functions compiled with.
I need to know exact type conversions in C# for those two labview functions. Or at least to C++ then I might able to convert them to C#.
The function calls were tested with Labview runtime engine and the engine seems recognizing. The error currently I am having is "AccessViolationException was unhandled"
ErroMessage: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Thanks in advance for anyone trying to help.
You need to look in extcode.h
to see the definitions of the various types. I found an instance online here:
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;
To summarize, all of your types are either int
or IntPtr
:
MgErr: int
File: IntPtr
Path: IntPtr
int32: int
PStr: IntPtr
LVRefNum: int
Here's how you might declare the functions:
int FCreate(IntPtr* fdp, IntPtr path, int permissions,
int openMode, int denyMode, IntPtr group);
int FNewRefNum(IntPtr path, IntPtr fd, int* refNumPtr);
精彩评论