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(); } }输出:
新闻热点
疑难解答
图片精选