c++代碼
#include "stdafx.h"extern "C" _declspec(dllexport) char* GetJson(char* pStr){ return "abcdefg";}c#代碼public class CC { [DllImport("Win32PRoject1.dll", EntryPoint = "GetJson", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr GetSnrJson([MarshalAs(UnmanagedType.LPStr)]string temp); public void Do() { StringBuilder sb = new StringBuilder(@"test"); IntPtr pStr = GetSnrJson(sb.ToString()); string json = Marshal.PtrToStringAnsi(pStr); Console.ReadLine(); } }輸出:
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注