UnmanagedãªDLLã®èªã¿è¾¼ã¿
http://d.hatena.ne.jp/yaneurao/20060315#p1
ãã£ããåºé
ããã®ã§ãèªåã®æ¥è¨ã§ã
UnmanagedãªDLLã¯.NETã®ç®¡è½å¤ãªã®ã§ãå®å ¨ã«ã³ã³ããã¼ã«ããã®ã¯ç¡çã§ããããã§CLRãã¹ãã£ã³ã°ã»ã»ã»ã¨ãè¨ãããã¨ããã§ãããããããã¨Win32ã©ã£ã·ãã«ãªããLinux/Macã§åä½ããããã¨ãå°é£ã«ãªãã¾ããåã³ã³ãã¤ã«ã許ãããã®ãªããã½ã¼ã¹ä¸ã«ãã£ããæ¸ãã¦ãã¾ãã®ãä¸ã¤ã®æã§ãã
using System; using System.Runtime.InteropServices; class Program { const string DLL = @"lib\func.dll"; [DllImport(DLL)] public static extern int Add(int x, int y); [DllImport(DLL)] public static extern int Sub(int x, int y); public static void Main () { Console.WriteLine (Add(10, 20)); Console.WriteLine (Sub(10, 20)); } }
ããã£ãã¼ãã¯ããªãã«ã ã®ååã§åé¡ãåãããããï¼(^^;
ã¨ããã§ãDllImportã«æ¸¡ãDLLåããªã½ã¼ã¹ããå¼ã£å¼µãäºã£ã¦åºæ¥ã¾ããã£ãï¼ ããå¯è½ãªãåãè¾¼ã¿ãªã½ã¼ã¹ã®æ¸ãæãã«ããæ¹ãã¹ãã¼ãã§ããã