c# 에서 c++(dll)로 LPCTSTR parameter 넘겨 호출 하기

c++ 로 된 dll을 c#에서 호출할때 예제입니다. 먼저 c++ 코드들을 간단히 짰습니다. test.h 1 extern "C" __declspec(dllexport) int test(LPCTSTR szFileName); test.cpp 1 2 3 int test(LPCTSTR szFileName) { return 0; } 다음은 c#쪽 코드들입니다 1 2 3 4 5 6 7 8 9 [DllImport("sampleLib.dll", CallingConvention = CallingConvention.Cdecl)] private static extern int test( [MarshalAs(UnmanagedType.LPWStr)] string szFileName); private void button2_Click(object sender, EventArgs e) { string szFileName = @"c:\filename.txt"; int result = test(ticketName); Debug....

October 15, 2015 · 1 min · 페이퍼