2011年5月16日 星期一

[C#] String 處理, 簡體 轉 繁體

有兩種作法  ,  第一種 是引用 Microsoft.VisualBasic  ,第二種 是引用 作業系統 Dll
但是第一種 有時候轉完 會出現?號,原因不明 (時間關係 所以沒繼續追 下去)

1.)
Microsoft.VisualBasic 加入參考
 private string CHT_TO_BIG5(string str)
        {
            return Microsoft.VisualBasic.Strings.StrConv(str, Microsoft.VisualBasic.VbStrConv.TraditionalChinese, 0);
        }

2.)
 //字串轉 繁體 使用
        internal const int LOCALE_SYSTEM_DEFAULT = 0x0800;
        internal const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
        internal const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
        [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
        internal static extern int LCMapString(int Locale, int dwMapFlags, string lpSrcStr, int cchSrc, [Out] string lpDestStr, int cchDest);

 private string String_To_BIG5(string str)
        {
            String tTarget = new String(' ', str.Length);
            int tReturn = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_TRADITIONAL_CHINESE, str, str.Length, tTarget, str.Length);
            return tTarget;
        }

[Other] 利用Reg.exe 快速開啟/關閉 螢幕保護程式

因為工作上的需求 需要能夠 快速開啟/關閉  螢幕保護程式

//這一行是將 螢幕保護 指定開啟 C:\Windows\system32\scrnsave.scr
reg add "HKCU\Control Panel\Desktop" /v SCRNSAVE.EXE /t reg_sz /d C:\Windows\system32\scrnsave.scr /f
//指定系統閒置 300秒 開啟螢幕保護啟動
reg add "HKCU\Control Panel\Desktop" /v ScreenSaveTimeOut /t reg_sz /d 300 /f
//開啟  若設為0  表示關閉
reg add "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t reg_sz /d 1 /f

2011年5月6日 星期五

[Other] 快速開關 IE Proxy ,一鍵搞定

建個批次檔  例如  Open.bat

快速開啟 Proxy:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 1 /f


關閉 Proxy:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t reg_dword /d 0 /f

2011年4月27日 星期三

[C#] 移動滑鼠游標到 x,y 位置

紀錄一下,移動滑鼠游標到某個按鍵上


        [DllImport("user32.dll")]
        static extern bool GetCursorPos(ref Point lpPoint);


 Cursor.Position = new Point(btn2.Location.X + this.Left + 34, btn2.Location.Y + this.Top + 47);

2011年4月12日 星期二

[C# ASP.NET] Server Error in '/' Application.

執行 ASP.NET 2008 的時候,出現錯誤。

Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.


解決方法是