2013-07-30 123 views
0

我用labview製作了一個互操作的assembly.net dll,它接受參數圖像,對圖像做一些處理然後返回圖像。Labview互操作程序集,在c#和labview之間交換圖像

當我將dll添加到我的c#.net項目後,我無法弄清楚帶有帶有labview的圖像數據類型的引用爲「LVBaseRefnum」的數據類型。 我已經成功調用簡單的數據類型和集羣類型,但我不知道什麼c#數據類型與「LVBaserefnum」一起使用,或者什麼數據類型與圖像對象一起使用。

另一方面,LVBaserefnum有一個構造函數,它將int refnum作爲參數。

LVBaseRefnum img = new LVBaseRefnum(int RefNum) 

有沒有人有想法?

+0

什麼是你變成一個DLL的LabVIEW代碼?特別是數據類型? –

回答

0

我想你在Lab View Application Builder中有標準的C/C++構造函數。
如果是的話,你有指針。在C#中,你必須聲明類和自編譯的程序集的使用(我想互操作程序集)爲不安全

class FileReader 
{ 
    const uint GENERIC_READ = 0x80000000; 
    const uint OPEN_EXISTING = 3; 
    IntPtr handle; 

    [DllImport("kernel32", SetLastError=true)] 
    static extern unsafe IntPtr CreateFile(
     string FileName,     // file name 
     uint DesiredAccess,     // access mode 
     uint ShareMode,      // share mode 
     uint SecurityAttributes,   // Security Attributes 
     uint CreationDisposition,   // how to create 
     uint FlagsAndAttributes,   // file attributes 
     int hTemplateFile     // handle to template file 
     ); 

    [DllImport("kernel32", SetLastError=true)] 
    static extern unsafe bool ReadFile(
     IntPtr hFile,      // handle to file 
     void* pBuffer,      // data buffer 
     int NumberOfBytesToRead,   // number of bytes to read 
     int* pNumberOfBytesRead,   // number of bytes read 
     int Overlapped      // overlapped buffer 
     );