作者a911zip (a911zip)
标题Re: [问题] 关於呼叫C++ dll function的问题
时间Tue Sep 30 11:56:04 2014
你可以试用 宣告 MarshalAs(UnmanagedType.LPArray)] byte[] intput 再宣告 byte[] outlist 丢入 看看
※ 引述《whatbb123 (湾湾)》之铭言:
: 各位大大好
: 我利用c#写网页并呼叫c++ dll档里的function
: 在dll里function里的变数为PBYTE与ULONG
: 如下(以下是一行,为了方便阅读我把它切了一下):
: extern "C" __declspec(dllexport)void
: GetAuthString(PBYTE pInBuf, ULONG ulInSize);
: 然後我利用c#写成的网页接了一字串
: 字串名称暂且称AuthStr = "477-61-F3-43A-46B-32E-589-4C4-4BD"
: 并试着传入GetAuthString中
: [DllImport("AuthProc.dll", EntryPoint = "GetAuthString",
: CallingConvention = CallingConvention.Cdecl)]
: static extern int GetAuthString(
: byte[] pInBuf,
: UInt32 ulInSize
: );
: 先载入dll档後,再将参数个别填入
: 其中pInBuf必须带入AuthStr
: ulInSize 为字串长度
: 我试着将string转型後代入function中
: 但结果仍失败。。。
: 是因为c++对应的c#型别是错误的吗?
: 麻烦各位先进了
: 谢谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 210.59.152.43
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1412049366.A.B18.html