下雪程序
我这有个桌面下雪的程序,但一直看不懂,麻烦各位帮我解答解答这里每个函数有什么用?这个是win32的程序,这个感觉很难,不懂
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Text;
namespace Snow
{
public class Win32
{
#region Win API functions
public delegate void TimerProc(IntPtr hwnd, uint uMsg, uint idEvent, uint dwTime);//产生时间
[DllImport("user32.dll")]
public static extern uint SetTimer(IntPtr hwnd, uint nIDEvent, uint uElapse, TimerProc lpTimerFunc);//设置时间
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);//查找窗口,是否越界
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hwnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RedrawWindow(IntPtr hWnd, ref RECT lprcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags);
[DllImport("user32")]
public static extern int ReleaseDC(IntPtr hwnd, IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern int SaveDC(IntPtr hdc);
[DllImport("gdi32.dll")]
public static extern IntPtr CreatePen(int fnPenStyle, int nWidth, int crColor);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool LineTo(IntPtr hdc, int nXEnd, int nYEnd);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MoveToEx(IntPtr hdc, int X, int Y, IntPtr lpPoint);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool RestoreDC(IntPtr hdc, int nSavedDC);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject(IntPtr hObject);
#endregion
#region Win API constants
public const int WM_TIMER = 0x0113;
public const int PS_SOLID = 0;
#endregion
#region Structs
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
public RECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
#region Win API enums
public enum RedrawWindowFlags
{
RDW_INVALIDATE = 0x0001,
RDW_NOERASE = 0x0020,
RDW_ERASE = 0x0004,
RDW_UPDATENOW = 0x0100
}
#endregion
#endregion
}
}
另外这有全部的代码 --------------------编程问答-------------------- 这里只是对api的声明,根本不涉及任何实质性的代码 --------------------编程问答-------------------- 那这段代码是需要自己写的吗?
(我是初学C#的) --------------------编程问答-------------------- 你的目的是什么??
想修改? --------------------编程问答-------------------- 说不是一两句能说清的,这些都是常见的 API 函数,搜索每个函数名,有大量的文章帖子解释这些 --------------------编程问答-------------------- 典型的API函数,这些东西都是规定死的,知道怎么用就行啊,没必要去深追究啊!!! --------------------编程问答-------------------- API声明而已,不需要写,用pinvoke工具就能导入,个别没有的再自己转 --------------------编程问答-------------------- lz想问什么
这些只是封装好了的api函数
去百度一下 --------------------编程问答-------------------- 这些只是API函数,不用研究为什么知道是什么功能需要的时候拿来用就好了!
补充:.NET技术 , C#