[問題] C++的dll用在C#中
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC 2010
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
無
問題(Question):
手上有個DLL, 我有原始檔
我想要引用他的一個function
DECLDIR BOOL Get301SSnapbStatus(BYTE* bStatus);
所以我在C#中這樣使用
[DllImport("UVCXUControl.dll")]
public static extern bool Get301SSnapbStatus(byte bStatus);
然後
但是他說無法載入, 找不到指定模組
上一次我這樣引入另一個dll的時候沒問題
這次出現這狀況不知道是他抓不到dll還是抓不到function
我有把dll搬到目錄下了
餵入的資料(Input):
byte
預期的正確結果(Expected Output):
因為他是連接一個device
理論上會持續回傳false
如果有抓到就是true
錯誤結果(Wrong Output):
不知是抓不到dll還是抓不到內部的function
程式碼(Code):(請善用置底文網頁, 記得排版)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace captu
{
public partial class Form1 : Form
{
Byte SnapShotbStatus = 0;
[DllImport("UVCXUControl.dll")]
public static extern bool Get301SSnapbStatus(byte bStatus);
public Form1()
{
InitializeComponent();
MessageBox.Show(Get301SSnapbStatus(SnapShotbStatus).ToString());
}
}
}
補充說明(Supplement):
這程式碼只是想要先抓到她回傳false的值
確定可以用才想說再來改
不過主要想問的是
如果遇到這種狀況是DLL真的不能用在C#
還是其他問題呢@@?
--
累積...http://wandal-lin.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.62.181
→
08/30 17:05, , 1F
08/30 17:05, 1F
→
08/30 17:06, , 2F
08/30 17:06, 2F
→
08/30 17:10, , 3F
08/30 17:10, 3F
→
08/30 17:10, , 4F
08/30 17:10, 4F
→
08/30 17:10, , 5F
08/30 17:10, 5F
→
08/30 17:11, , 6F
08/30 17:11, 6F
→
08/30 17:11, , 7F
08/30 17:11, 7F
→
08/30 17:14, , 8F
08/30 17:14, 8F
→
08/30 17:24, , 9F
08/30 17:24, 9F
推
08/30 17:35, , 10F
08/30 17:35, 10F
→
08/30 20:59, , 11F
08/30 20:59, 11F
→
08/30 21:14, , 12F
08/30 21:14, 12F
推
08/30 21:39, , 13F
08/30 21:39, 13F
→
08/30 21:40, , 14F
08/30 21:40, 14F
→
08/31 04:29, , 15F
08/31 04:29, 15F
→
08/31 08:41, , 16F
08/31 08:41, 16F
→
08/31 08:41, , 17F
08/31 08:41, 17F
→
08/31 08:42, , 18F
08/31 08:42, 18F
→
08/31 08:42, , 19F
08/31 08:42, 19F
推
08/31 08:45, , 20F
08/31 08:45, 20F
→
08/31 09:47, , 21F
08/31 09:47, 21F
→
08/31 09:47, , 22F
08/31 09:47, 22F
→
08/31 09:47, , 23F
08/31 09:47, 23F
→
08/31 09:47, , 24F
08/31 09:47, 24F