回 帖 发 新 帖 刷新版面

主题:[ ] 里面加点内容到底什么意思啊? 还请高手来解答一下

[color=FF0000][DllImport("user32.dll")][/color] private static extern 
   bool SetForegroundWindow(IntPtr hWnd);
[color=FF0000][DllImport("user32.dll")][/color] private static extern 
   bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[color=FF0000][DllImport("user32.dll")][/color] private static extern 
   bool IsIconic(IntPtr hWnd);

回复列表 (共1个回复)

沙发

[]在这里表示Attribute,它对程序中的元素进行标注,如类型、字段、方法和属性等。Attributes和Microsoft .NET Framework文件的元数据保存在一起,可以用来向运行时描述你的代码,或者在程序运行的时候影响应用程序的行为.DllImport这个attribute表示引用一个外部的dll文件,由于你这些函数需要引用user32.dll里的方法,而这个dll又不是系统自带的所以需要使用此attribute引进来.关于attribute的详细解释请看
http://blog.programfan.com/article.asp?id=26725

我来回复

您尚未登录,请登录后再回复。点此登录或注册