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 Microsoft;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace Process
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Regedit.dll")]//声明DLL
public static extern string GetRegedit(string File);//声明DLL函数,获取指定注册项内容
[DllImport("Regedit.dll")]//声明DLL
public static extern bool REGRegedit(string File, string Text);//声明DLL函数,写指定注册项内容
private void button2_Click(object sender, EventArgs e)
{
bool VALL;
VALL = REGRegedit("SOFTWARE/OneChina/Operation", textBox1.Text);//写指定注册项内容
MessageBox.Show(VALL.ToString());
}
private void button4_Click(object sender, EventArgs e)
{
string VALL;
VALL = GetRegedit("SOFTWARE/OneChina/Operation");//获取指定注册项内容
MessageBox.Show(VALL);
}
private void Form1_Load(object sender, EventArgs e)
{
//清空所有项
listBox1.Items.Clear();
listBox1.Items.Add("111111");
listBox1.Items.Add("222222");
listBox1.Items.Add("333333");
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(listBox1.Items.Count>0)
{
//if (GetList(this.listBox1.SelectedItem.ToString()) != false)
//{
checkedListBox1.Items.Add(this.listBox1.SelectedItem.ToString());
//}
}
}
//public bool GetList(string Text)
//{
// bool Dates;
// Dates = true;
// for (int i = 1; i <= checkedListBox1.Items.Count; i++)
// this.checkedListBox1.SelectedIndex = this.checkedListBox1.SelectedIndex + 1;
// string vall;
// vall = this.checkedListBox1.SelectedValue.ToString();
// if (vall == Text)
// {
// Dates = true;
// }
// else
// {
// Dates = false;
// }
// return Dates;
//}
private void button1_Click(object sender, EventArgs e)
{
string[] array;
string a="a|b|c|d|e";
array=a.Split('|');
MessageBox.Show(array[0]);
MessageBox.Show(array[1]);
MessageBox.Show(array[2]);
MessageBox.Show(array[3]);
MessageBox.Show(array[4]);
}
private void button3_Click(object sender, EventArgs e)
{
string output = string.Empty;
for (int i = 0; i < checkedListBox1.CheckedIndices.Count; i++)
{
if( i+1 == checkedListBox1.CheckedIndices.Count)
{
output += checkedListBox1.Items[checkedListBox1.CheckedIndices[i]].ToString();
}
else
{
output += checkedListBox1.Items[checkedListBox1.CheckedIndices[i]].ToString() + "|";
}
}
textBox1.Text = output;
}
private void button5_Click(object sender, EventArgs e)
{
comboBox1.Items.Clear();
string[] array;
string a ;
a = GetRegedit("SOFTWARE/OneChina/Operation");
MessageBox.Show(a);
array = a.Split('|');
for (int i = 0; i < array.Length; i++)
{
if (array[i] != "?")
{
comboBox1.Items.Add(array[i]);
}
}
if (comboBox1.Items.Count > 0)
{
comboBox1.SelectedIndex = 0;
}
a = "";
}
}
}
C# 数据操作
最新推荐文章于 2023-08-01 14:57:46 发布