06-系统操作/设置桌片壁纸/APIdesktop/Form1.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using System.Drawing.Imaging;
namespace APIdesktop
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        #region 调用API
        [DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")]
        static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, string lpvparam, Int32 fuwinIni);
        private const int SPI_SETDESKWALLPAPER = 20;
        #endregion
        Form2 frm2;
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                listView1.Items.Clear();
                string[] files = openFileDialog1.FileNames;
                string[] fileinfo = new string[3];
                for (int i = 0; i < files.Length; i++)
                {
                    string path = files[i].ToString();
                    string fileName = path.Substring(path.LastIndexOf("\\") + 1, path.Length - 1 - path.LastIndexOf("\\"));
                    string filetype = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - 1 - fileName.LastIndexOf("."));
                    fileinfo[0] = fileName;
                    fileinfo[1] = path;
                    fileinfo[2] = filetype;
                    ListViewItem lvi = new ListViewItem(fileinfo);
                    listView1.Items.Add(lvi);
                }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int x = this.Location.X;
            int y = this.Location.Y;
            frm2 = new Form2();
            frm2.x = x + this.Width;
            frm2.y = y;
            frm2.Hide();
            openFileDialog1.Filter = "支持的图片格式|*.jpeg;*.png;*.bmp;*.jpg";
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
后面还有 110 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。