[問題] 使用dll的問題。

看板C_Sharp作者 (Oh Yes)時間15年前 (2010/12/21 18:30), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
dll 的function 原型 使用dll viewer 看的 unsigned char HIDtoUARTDevice_SetOutputReport_Interrupt(unsigned char *,unsigned long) 我在c# 中有使用DllImport,但是一直都無法成功。後來亂試看哪一種可以, 但都還是失敗。以下為我試過的,麻煩大家告訴我應該要怎麼改才對。 http://nopaste.csie.org/67493 <= 比較好看的程式碼 [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control(ref byte[] buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control1(ref byte buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control2(byte[] buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control3(byte buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control4(string buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control5([MarshalAs(UnmanagedType.LPWStr)] string buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control6([MarshalAs(UnmanagedType.LPTStr)] string buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control7([MarshalAs(UnmanagedType.LPArray)] byte[] buffer, ulong length); [DllImport("DLLCHID7.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.ThisCall, EntryPoint = "#15")] public static extern char HIDtoUARTDevice_SetOutputReport_Control8([MarshalAs(UnmanagedType.LPArray)] string buffer, ulong length); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.20.163.200

12/21 20:16, , 1F
EntryPoint似乎不對
12/21 20:16, 1F

12/21 21:06, , 2F
EntryPoint 有確認過,是沒錯的。
12/21 21:06, 2F
文章代碼(AID): #1D487EFu (C_Sharp)