⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmabout.cs

📁 OPC CLIENT开发包
💻 CS
字号:
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System;
using System.Text;
internal partial class frmAbout : System.Windows.Forms.Form
{
	const int KEY_ALL_ACCESS = 131135;
	const int HKEY_LOCAL_MACHINE = -2147483646;
	const short ERROR_SUCCESS = 0;
	const short REG_SZ = 1;
	const short REG_DWORD = 4;


	const string gREGKEYSYSINFOLOC = "SOFTWARE\\Microsoft\\Shared Tools Location";
	const string gREGVALSYSINFOLOC = "MSINFO";
	const string gREGKEYSYSINFO = "SOFTWARE\\Microsoft\\Shared Tools\\MSINFO";
	const string gREGVALSYSINFO = "PATH";
	[DllImport("advapi32", EntryPoint = "RegOpenKeyExA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
	private static extern int RegOpenKeyEx(int hKey, string lpSubKey, int ulOptions, int samDesired, ref int phkResult);
	[DllImport("advapi32", EntryPoint = "RegQueryValueExA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
	private static extern int RegQueryValueEx(int hKey, string lpValueName, int lpReserved, ref int lpType, byte[] lpData, ref int lpcbData);
	[DllImport("advapi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
	private static extern int RegCloseKey(int hKey);



	private void frmAbout_Load(object eventSender, System.EventArgs eventArgs)
	{
        //lblVersion.Text = "Version " + Application.ver.Info.Version.Major + "." + Application.Info.Version.Minor + "." + Application.Info.Version.Revision;
        //lblTitle.Caption = App.Title;
	}



	private void cmdSysInfo_Click(object eventSender, System.EventArgs eventArgs)
	{
		StartSysInfo();
	}


	private void cmdOK_Click(object eventSender, System.EventArgs eventArgs)
	{
		this.Close();
	}

    [DllImport("shell32.dll",   EntryPoint="ShellExecute")]   
    public   static   extern   int   ShellExecute   (int   hwnd,string   lpOperation,string   lpFile,string   lpParameters,string   lpDirectory,int   nShowCmd);   

	public void StartSysInfo()
	{
        //int rc;
		string SysInfoPath;
		SysInfoPath = "";
        if (!GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO,ref SysInfoPath))
        {
            if (GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC,ref SysInfoPath))
            {
                if ((System.IO.File.Exists(SysInfoPath + "\\MSINFO32.EXE")))
                {
                    SysInfoPath = SysInfoPath + "\\MSINFO32.EXE";
                }
                else
                {
                    goto SysInfoErr;
                }
            }
            else
            {
                goto SysInfoErr;
            }
        }
        ShellExecute(0,"open",SysInfoPath,null,Application.StartupPath,1);   
        SysInfoErr:
		return;
	}


	public bool GetKeyValue( int KeyRoot,  string KeyName,  string SubKeyRef, ref string KeyVal)
	{
		bool functionReturnValue = false;
		int I;
		int rc;
		int hKey=0;
		//Dim hDepth As Integer '
		int KeyValType=0;
		byte[] tmpVal=new byte[128];
		int KeyValSize=0;
		rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, ref hKey);
		if ((rc != ERROR_SUCCESS)) goto GetKeyError; 
		KeyValSize = 1024;
		rc = RegQueryValueEx(hKey, SubKeyRef, 0, ref KeyValType, tmpVal,ref KeyValSize);
        ASCIIEncoding encoding = new ASCIIEncoding();
		if ((rc != ERROR_SUCCESS)) goto GetKeyError;
        tmpVal[KeyValSize] = 0;
		switch (KeyValType) {
			case REG_SZ:

				KeyVal = encoding.GetString(tmpVal);
				break;
			case REG_DWORD:
				for (I = tmpVal.Length ; I >= 1; I += -1) {
                 //   KeyVal = KeyVal + Conversion.Hex(Strings.Asc(tmpVal.Substring(I, 1)));
				}

				KeyVal = "&h" + KeyVal;
				break;
		}
		functionReturnValue = true;
		rc = RegCloseKey(hKey);
		return true ; // TODO: might not be correct. Was : Exit Function
		GetKeyError:

		KeyVal = "";
		functionReturnValue = false;
		rc = RegCloseKey(hKey);
		return functionReturnValue;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -