还是上学期写的东西了,既然第一次在这写博,就发点好东西给大家哈……
这只给出其中的关于文件夹的类
有需要本软件或源代码的请在本帖下跟帖,并留下你的邮箱,完全免费哈!
ChangeFolder 类:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Security.Cryptography;
using Microsoft.Win32;
using System.Diagnostics;
namespace FolderTool
{
class ChangeFolder
{
[DllImport(kernel32)]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport(kernel32)]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
private string pathOfFolder;
public ChangeFolder() { ;}
public ChangeFolder(string pathOfFolder)
{
this.pathOfFolder = pathOfFolder;
}
public void ChangeIcon(string iconPath, string index)
{
中文写代码软件
if (System.IO.File.Exists(pathOfFolder + \\desktop.ini))
{
System.IO.FileInfo fi = new System.IO.FileInfo(pathOfFolder + \\desktop.ini);
if (fi.Attributes.ToString().IndexOf(ReadOnly) != -1)
fi.Attributes = System.IO.FileAttributes.Normal;
}
string section = .ShellClassInfo;
string key1 = IconIndex;
string key2 = IconFile;
WritePrivateProfileString(section, key1, index, pathOfFolder + \\desktop.ini);
WritePrivateProfileString(section, key2, iconPath, pathOfFolder + \\desktop.ini);
System.IO.File.SetAttributes(pathOfFolder, System.IO.FileAttributes.System);
System.IO.File.SetAttributes(pathOfFolder + \\desktop.ini, System.IO.FileAttributes.System | System.IO.FileAttributes.ReadOnly | System.IO.FileAttri
butes.Hidden);
}
public void ChangeImage(string imagePath)
{
if (System.IO.File.Exists(pathOfFolder + \\desktop.ini))
{
System.IO.FileInfo fi = new System.IO.FileInfo(pathOfFolder + \\desktop.ini);
if (fi.Attributes.ToString().IndexOf(ReadOnly) != -1)
fi.Attributes = System.IO.FileAttributes.Normal;
}
string section1 = ExtShellFolderViews;
string section2 = {BE098140-A513-11D0-A3A4-00C04FD706EC};
string key = IconArea_Image;
WritePrivateProfileString(section1, {BE098140-A513-11D0-A3A4-00C04FD706EC}, {BE098140-A513-11D0-A3A4-00C04FD706EC}, pathOfFolder + \\desktop.ini);
WritePrivateProfileString(section2, key, imagePath, pathOfFolder + \\desktop.ini);
System.IO.File.SetAttributes(pathOfFolder, System.IO.FileAttributes.System);
System.IO.File.SetAttributes(pathOfFolder + \\desktop.ini, System.IO.FileAttributes.System | System.IO.FileAttributes.ReadOnly | System.IO.FileAttributes.Hidden);
}
public void Disguise(int type)
{
if (System.IO.File.Exists(pathOfFolder + \\desktop.ini))
{
System.IO.FileInfo fi = new System.IO.FileInfo(pathOfFolder + \\desktop.ini);
if (fi.Attributes.ToString().IndexOf(ReadOnly) != -1)
fi.Attributes = System.IO.FileAttributes.Normal;
}
if (type < 6 && type >= 0)
{
System.IO.File.Delete(pathOfFolder + \\desktop.ini);
string[] list = new string[6];
list[0] = {645FF040-5081-101B-9F08-00AA002F954E};
list[1] = {20D04FE0-3AEA-1069-A2D8-08002B30309D};
list[2] = {21ec2020-3aea-1069-a2dd-08002b30309d};
list[3] = {208D2C60-3AEA-1069-A2D7-08002B30309D};
list[4] = {7007ACC7-3202-11D1-AAD2-00805FC1270E};
list[5] = {D6277990-4C6A-11CF-8D87-00AA0060F5BF};
string section = .ShellClassInfo;
string key = CLSID;
string value = list[type];
WritePrivateProfileString(section, key, value, pathOfFolder + \\desktop.ini);
System.IO.File.SetAttributes(pathOfFolder + \\desktop.ini, System.IO.FileAttributes.System | System.IO.FileAttributes.ReadOnly | System.IO.FileAttri
butes.Hidden);
System.IO.File.SetAttributes(pathOfFolder, System.IO.FileAttributes.System);
}
else
{
System.IO.File.Delete(pathOfFolder + \\desktop.ini);
}
}
public void Encrypt(string password)
{
string regName = pathOfFolder;
string regValue = UserMd5(password);
RegistryKey hklm = Registry.LocalMachine;
RegistryKey software = hklm.OpenSubKey(SOFTWARE, true);
RegistryKey aimdir = software.CreateSubKey(FolderTool);
aimdir.SetValue(regName, regValue);
string drivePath = pathOfFolder.Substring(0, 2);
Process p = new Process();
p.StartInfo.FileName = ;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;