'我用一個命令按鈕來執行寫入操作。 private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click '如果沒有存在事件源的話就新建一個 if not eventlog.sourceexists("writetoevent") then eventlog.createeventsource("writetoevent", "application") 'application是表示放于應用程序事件中 end if eventlog1.source = "writetoevent" eventlog1.writeentry("在這里我執行一個寫入測試。") '執行寫入操作。 end sub