C# 操作INI文件的类

C# 操作INI文件的类

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

namespace server
{
    class IniFile   // revision 11
    {
        string Path;
        string EXE = Assembly.GetExecutingAssembly().GetName().Name;

        [DllImport("kernel32", CharSet = CharSet.Unicode)]
        static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);

        [DllImport("kernel32", CharSet = CharSet.Unicode)]
        static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath);

        public IniFile(string IniPath = null)
        {
            Path = new FileInfo(IniPath ?? EXE + ".ini").FullName.ToString();
        }

        public string Read(string Key, string Section = null)
        {
            var RetVal = new StringBuilder(255);
            GetPrivateProfileString(Section ?? EXE, Key, "", RetVal, 255, Path);
            return RetVal.ToString();
        }

        public void Write(string Key, string Value, string Section = null)
        {
            WritePrivateProfileString(Section ?? EXE, Key, Value, Path);
        }

        public void DeleteKey(string Key, string Section = null)
        {
            Write(Key, null, Section ?? EXE);
        }

        public void DeleteSection(string Section = null)
        {
            Write(null, null, Section ?? EXE);
        }

        public bool KeyExists(string Key, string Section = null)
        {
            return Read(Key, Section).Length > 0;
        }
    }
}

PDO execute()和exec()的区别

PDO execute()和exec()的区别如下:

exec() 执行一条sql语句,返回受影响的行数,此函数不返回结果集合。

execute()函数 用于执行已经预处理过的语句,返回结果只有成功或失败。预处理要使用prepare函数

使用execute()如果要获取受影响的行数,可以在调用execute()后 调用: $stmt->rowCount();来获取受影响的行数

php.ini 打开错误信息

php.ini 打开错误信息,修改如下配置:

display_errors=On
error_reporting = E_ALL | E_STRICT

如果使用apache,则要在httpd.conf最后添加 

php_flag display_errors on
php_value error_reporting 2039

最后重启apache

反射实现 WPF 按钮的  PerformClick 

反射实现 WPF 按钮的  PerformClick:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
namespace cmbc
{
    static public class  ButtonEx
    {
        public static void PerformClick(this ButtonBase button)
        {
            var method = button.GetType().GetMethod("OnClick",
                BindingFlags.NonPublic | BindingFlags.Instance);
            if (method != null)
            {
                method.Invoke(button, null);
            }
            //button.Focus();
        }
    }
}

Qt Quick 中最大化窗体

Qt Quick 中最大化窗体:

import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    visible: true
   // width: 640
   // height: 480

         visibility: "Maximized" // 全屏使用 FullScreen

    title: qsTr("民生银行触摸屏程序")

    MainForm {
        anchors.fill: parent
        mouseArea.onClicked: {
            Qt.quit();
        }

    }
}