日期:2014-05-17  浏览次数:20838 次

关于C#的特性 类中的DllImport
 
        [DllImport("coredll.dll", EntryPoint = "ShowWindow")]
        public static extern int ShowWindow(int hwnd, int nCmdShow);
        public const int SW_SHOW = 5; public const int SW_HIDE = 0;

        [DllImport("coredll.dll", EntryPoint = "SystemParametersInfo")]
        private static extern int SystemParametersInfo(int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
        public const int SPIF_UPDATEINIFILE = 0x1;
        public const int SPI_SETWORKAREA = 47;
        public const int SPI_GETWORKAREA = 48;

        [DllImport("coredll.dll", EntryPoint = "FindWindow")]
        private static extern int FindWindow(string lpClassName, string lpWindowName);



求帮助,不需要都解释,拿出一两个说说这样写的意义是什么就行了。或者有什么资料吗?我看了一些,看不懂涉及的面太广,我就想知道这个类中为什么要这样写,有什么作用。
        
C# DllImport

------解决方案--------------------
API函数互操作,而且还是Windows CE上的。
        [DllImport("coredll.dll", EntryPoint = "ShowWindow")] //coredll.dll库中的ShowWindow函数,作用是显示或者隐藏函数
         public static extern int ShowWindow(int hwnd, int nCmdShow); //定义函数原型,hwnd为待窗体窗体句柄(一个用来代表窗体的标志id),nCmdShow为参数,传5表示显示,传0表示隐藏,这是微软规定的
         public const int SW_SHOW = 5; public const int SW_HIDE = 0; //为了便于程序员理解,用常量SW_SHOW代表5,用SW_HIDE代表0,这样我们可以用ShowWindow(hwnd, SW_SHOW)而不是ShowWindow(hwnd, 5),看上去前者更容易理解。SW表示这个参数是ShowWindow的,SHOW意思是显示,HIDE是隐藏。