這裡敘述的Hello Wolrd主要是利用Ben Hall的一篇文章Windows Live Writer Plugin - Hello World!。 (Related code and article refer from this)

必要工具:

  • Visual Studio (這裡用的是2005)

  • 安裝過的Window Live Writer (這裡裝的是最新版B14.0.8089)

詳細流程:

  • 開啟Visual Studio(2005),選取C# Project的Class Library。

WLW_01.jpg

  • 講兩個需要用的reference 加入參考,首先打開”References” 按下右鍵。”Add References”

WLW_02.jpg

  • 加入一個”System.Windows.Forms”在COM裡面,此外再加入一個額外Windows Live Writer API DLL。選取”Browse”然後點選C:Program FilesWindows LiveWriterWindowsLive.Writer.Api.dll。

WLW_03.jpg

  • 加入以下的source code. (This source modify from Ben Hall’s article)

    using System.Windows.Forms;
    </br>using WindowsLive.Writer.Api;
    </br>
    </br>namespace LiveWriterHelloWorld
    </br>{
    </br> [WriterPluginAttribute
    </br> (“2f437bf1-fe57-41c8-931a-d20066ea174e”, “Hello World!”,
    </br> PublisherUrl = “http://wlwextensionlearning.blogspot.com/”,
    </br> Description = “Insert Hello World! into the blog post”)]
    </br> [InsertableContentSourceAttribute(“Hello World!”, SidebarText = “Hello World!”)]
    </br> public class HelloWorldPlugin : ContentSource
    </br> {
    </br> public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
    </br> {
    </br> content = “Hello World!”;
    </br>
    </br> return DialogResult.OK;
    </br> }
    </br> }
    </br>}
    </br>

  • 複製DLL到C:Program FilesWindows LiveWriterPlugins 然後重新啟動Windows Live Writer應該就會看到這個新的plugin.

WLW_04.jpg

  • 直接按下去就會跑出 “Hello World”

參考文章:


Evan

Attitude is everything