2014-02-07 45 views
0

我最近買了一個指紋暨讀卡機。隨之而來的是API,以便我可以通過我的電腦通過網絡使用它。問題是,我正在構建基於C#.net的應用程序,並且api文檔說建立在vb上。其次,我無法在我的C#應用​​程序中包含和使用它。使用基於VB的DLL和/或ocx文件在C#

請試試看,並告訴我如何在我的c#應用程序中使用它。完整的api rar文件鏈接如下。請下載ND幫助

鏈接:http://www.4shared.com/rar/TfD6vyOdce/SDK.html

回答

0

第一個選項是:

Add the DLL via the solution explorer - right click on references --> 
add reference then "Browse" to you DLL - then it should be available. 

二,選項是: //非託管C++ DLL例如:

using System; 
using System.Runtime.InteropServices; 

//你可能需要使用DllImport

[DllImport(@"C:\Cadence\SPB_16.5\tools\bin\mpsc.dll")] 
static extern void mpscExit(); 

//或

[DllImport("user32.dll", CharSet = CharSet.Unicode)] 
    public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type); 

//然後每個那些被稱爲是這樣的:

mpscExit(); // a specific DLL method/function call 
MessageBox(new IntPtr(0), "Test", "Test Dialog", 0); 

// user32.dll中是微軟,路徑不東東在控制檯

小exapmle應用程序

using System; 
using System.Runtime.InteropServices;  // DLL support 

class HelloWorld 
{ 
    [DllImport("TestLib.dll")] 
    public static extern void DisplayHelloFromDLL(); 

    static void Main() 
    { 
     Console.WriteLine ("This is C# program"); 
     DisplayHelloFromDLL(); 
    } 
} 
+0

先生,您的代碼在Vbasic中。只要打開rar文件,你會發現一個dll nd ocx。我如何在我的C#應用​​程序中使用它們來讀取機器的輸入。 –

+0

感謝您的回覆我是否也可以爲ocx文件使用相同的代碼? –

+0

可能對* .ocx文件也很有用 – jainvikram444