가면갈수록 어려워지니 쩝...
뭐 암튼...
test.dll이란 이름의 C++로 만들어진 DLL이 있다고 치자.
그리고 그것의 함수는 다음과 같다고 치자.
이녀석을 컴파일 하면 test.dll 이란게 생길것이다. 이녀석을 Debug라고하는 컴파일후 생성되는 폴더에 재주껏 넣어 놓고 다음과 같이 코딩해보자.
뭐 암튼...
test.dll이란 이름의 C++로 만들어진 DLL이 있다고 치자.
그리고 그것의 함수는 다음과 같다고 치자.
int returnInt(int a)
{
return a;
}
이녀석을 컴파일 하면 test.dll 이란게 생길것이다. 이녀석을 Debug라고하는 컴파일후 생성되는 폴더에 재주껏 넣어 놓고 다음과 같이 코딩해보자.
using System;
using System.Runtime.InteropServices; //여기 선언 중요
class InvokeTest
{
[DllImport("test.dll")] //만약 함수명이 다르면 EntryPoint="function_name" 지정
public static extern int returnInt(int a);//외부정의함수이므로 extern과 static필수
public static void Main()
{
int i = returnInt(1);
Console.WriteLine(i);
}
}






283818
232
351









댓글을 달아 주세요