Re: [問題] 關於 c# dllimport dll 傳入 char* 參數
[System.Runtime.InteropServices.DllImportAttribute("hyde_capture_dll.dll")]
private static extern int go_capture([MarshalAs(UnmanagedType.LPStr)]
string name);
這樣用可是每當執行到會有exception 丟出..搞不懂煩請指點
※ 引述《stellvia7 (stellvia)》之銘言:
: dll 中
: int go_capture(char *name)
: {
: printf("the name = %s\d",name);
: }
: c# 中
: [System.Runtime.InteropServices.DllImportAttribute("test.dll")]
: private static extern int go_capture(char *name);
: ...
: ...
: ...
: void button_click(....)
: {
: string abc="temp_name";
: go_capture(abc);
: }
: 上述 go_capture的用法我知道是錯的 但我try很久 有的說用unsafe
: 有個要用Inptr轉型 但是一直失敗 可以煩請指點嗎..
: 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.130.36.18
→
01/12 13:25, , 1F
01/12 13:25, 1F
→
01/12 14:16, , 2F
01/12 14:16, 2F
→
01/12 14:17, , 3F
01/12 14:17, 3F
→
01/12 14:17, , 4F
01/12 14:17, 4F
推
01/13 00:46, , 5F
01/13 00:46, 5F
推
01/15 23:46, , 6F
01/15 23:46, 6F
→
01/15 23:47, , 7F
01/15 23:47, 7F
→
01/15 23:48, , 8F
01/15 23:48, 8F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):