看板 C_Sharp 關於我們 聯絡資訊
※ 引述《spursGM (沉默而偉大的球隊)》之銘言: : 在C++ dll 程式概述如下: : char * test(void) : { : char testStr[]="Hello World!"; : return *testStr; : } : 在C#宣告如下: : static extern byte[] test(void); : 在C#使用如下: : try : { : byte[] output = test(); : String outputStr = System.Text.Encoding.Default.GetString(output); : label1.Text = outputStr; : } : catch (Exception ex) : { : label1.Text = ex.ToString(); : } C++ 不應在export時回傳void *類型. (pointer沒有鎖定, 記憶體擁有權 也不清楚...) 請把回傳的變數宣告成如void test(char * strRet)這樣... 另外在C#的宣告應改成: void test(System.Text.StringBuilder strRet)... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 202.134.126.84