星期日, 7月 08, 2007

取得其他Process的command line arguments

錯誤(失敗)的作法:
  • 在DotNET中使用Process class來取得ProcessStartInfo: 會得到一個空字串
  • 使用Windows API (如GetStartupInfo): 只能夠抓到目前Process的command line arguments
正確的作法:
  • 在DotNET中reference System.Management, 使用WMI
    ManagementObjectSearcher query = new ManagementObjectSearcher
    ("SELECT * FROM Win32_Process WHERE ProcessID=2860");
    ManagementObjectCollection queryCollection = query.Get();
    foreach (ManagementObject mo in queryCollection)
    {
    Console.WriteLine("PID [ {0} ] started With commandline - '{1}'",
    mo["ProcessID"].ToString(), mo["CommandLine"].ToString());
    }

    WMI介紹: http://www.csharphelp.com/archives2/archive334.html

  • 利用CreateRemoteThread來完成: http://win32.mvps.org/processes/remthread.html

    • 開啟目標process
    • 在目標process中分配兩塊記憶體。一塊存放程式碼,一塊存放資料。
    bullet
    • 複製程式碼到目標process
    bullet
    • 初始化目標process的資料記憶體區塊
    bullet
    • 呼叫CreateRemoteThread()執行先前複製到目標process的程式碼
    bullet
    • 等待remote thread結束
    bullet
    • 將執行結果從目標process的資料區塊複製回來

星期日, 7月 01, 2007

CruiseControl 1.3 Dashboard跑不起來

狀況:
(在Server本機開啟DashBoard得到以下訊息)

=== Pre-bind state information === LOG: DisplayName = ThoughtWorks.CruiseControl.WebDashboard (Partial) LOG: Appbase = file:///C:/Program Files/CruiseControl.NET/webdashboard LOG: Initial PrivatePath = bin Calling assembly : (Unknown). === LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Post-policy reference: ThoughtWorks.CruiseControl.WebDashboard LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/ccnet/12b02713/c7918020/ThoughtWorks.CruiseControl.WebDashboard.DLL. LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/ccnet/12b02713/c7918020/ThoughtWorks.CruiseControl.WebDashboard/ThoughtWorks.CruiseControl.WebDashboard.DLL. LOG: Attempting download of new URL file:///C:/Program Files/CruiseControl.NET/webdashboard/bin/ThoughtWorks.CruiseControl.WebDashboard.DLL.


解決方法:
因為CruiseControl 1.3已經升級為.NET 2.0,所以必須在IIS上將ccnet改成以.NET 2.0運作

星期三, 6月 13, 2007

星期四, 6月 07, 2007

星期三, 6月 06, 2007

Lua

星期一, 6月 04, 2007

如何不被 TortoiseSVN 拖慢系統效率 [JeffHung.Blog]

用了TortoiseSVN後系統似乎變慢了,以下文章說明如何增進系統效能:

* 如何不被 TortoiseSVN 拖慢系統效率 [JeffHung.Blog]
* Optimize Performance