using System; using System.Web; using AppModule.InterProcessComm; using AppModule.NamedPipes; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write(SendRequest("測試asdf")); } /// <summary> /// 測試namepiped客戶端 /// </summary> /// <param name="request">發送命令</param> /// <returns>返回數據</returns> string SendRequest(string request) { string response=""; IInterProcessConnection clientConnection = null; try { clientConnection = new ClientPipeConnection("np-test-by-jinjazz", "."); clientConnection.Connect(); clientConnection.Write(request); response=clientConnection.Read(); clientConnection.Close(); } catch (Exception ex) { clIEntConnection.Dispose(); response = ex.Message; } return response; } }
測試環境為Windows Vista和Windows2003