Change Location

MOVE to new place , click here, here (blogger) will not update anymore!

搬家了 搬到這邊, 舊家不會更新了喔!


Windows Live and WordPress

Now you can migrate your blog in windows live to wordpress.com...because they partnering toghter

現在Windows Live的Blog部分跟Wordpress合作了, 他有自動畫搬移的過程. 不過看起來account會變成以wordpress....嘖嘖嘖...


GetLastError and FormatMessage and NewLine

When we use FormatMessage to get the system error message by the DWORD(from GetLastError), we will get a LPTSTR that end with NewLine (CRLF). How to convert to be NULL end string? It’s a very easy way to do it:


Code Snippet
  1. CString CGetInfo::GetError(void){
  2.     LPVOID lpMsgBuf;
  3.     DWORD dw = GetLastError();
  5.     FormatMessage(
  9.         NULL,
  10.         dw,
  12.         (LPTSTR) &lpMsgBuf,
  13.         0, NULL );
  14.     CString s = (LPTSTR)lpMsgBuf;
  15.     s.Remove('\r');
  16.     s.Remove('\n');
  17.     return s;
  18. }

當我們在用win32 API裡面的FormatMessage去處理GetLastError傳出來的DWORD 錯誤碼的時候, FormatMessage會回傳一個LPTSTR, 以\r\n結尾的字串, 那怎麼把那個\r\n去掉呢? 其實很簡單, 用CString.Rmove() 兩行輕鬆解決.


FAST Admin Service

I am doing integration between FAST and Umbraco, and consider to decouple the FAST configuration and CMS environment.

Before go to do that I must find out a way to collect administration information from FAST. That is lucky that FAST do provide several web service to provide administration service.

It’s really simple to use the service. usually the admin service is locate at port 16089 and you can just reference the service as “http://host:16089/adminserver/servicename.jws”. and than you can use it as normal web service.

   1: FastAdminPresentationService.PresentationService ps = new FastAdminPresentationService.PresentationService();

   2: CredentialCache cc = new CredentialCache();

   3: cc.Add(new Uri("http:hostname:16089/adminserver/servicename.jws"),"Basic",new NetworkCredential("adminname", "adminpassword"));

   4: ps.Credentials = cc;

Following is the service I using and tested.

CollectionService.getCollectionNames <—get the collection names

IndexProfileService.getClusterNames() <—as name

IndexProfileService.getDeployedIndexProfile(ClusterName) <—get index profile xml

Get Search Profiles:

   1: FastAdminSearchProfilesService.SearchProfileRetrieveFilter filter = new FastAdminSearchProfilesService.SearchProfileRetrieveFilter();

   2: FastAdmiTest.FastAdminSearchProfilesService.SearchProfile[] list = sps.retrieveSearchProfiles(null, false, false, false);

Get the Navigators inside special Search Profile:

First, get the SearchProfile and keep the SearchProfile .publishedViewName, and then Reference PresentationService and get the navigator by publishedViewName as

Navigation navigation = ps.retrieveNavigation(the publishedViewName that we keeped);

Then, the navigation.navigators are what we want to have. If you want the list the same with the Admin Site UI showing, choice the navigators with blocked property be false.


Microsoft Officie 2010 does not support upgrading from a prerelease version of Microsoft Office 2010.

Remember remove Send a smile” before install Office 2010 RTM if you join the Microsoft Connect Office 2010 program. else, you will get this error message:

Setup is unable to proceed due to the following error(s):
Microsoft Officie 2010 does not support upgrading from a prerelease version of Microsoft Office 2010.  You must first uninstall any prerelease versions of Microsoft Office 2010 products and associated technologies.
Correct the issue(s) listed above and re-run setup.


[Umbraco] How to get media URL

Here is one way to do:

string s = string.Empty;
System.Xml.XPath.XPathNavigator n = umbraco.library.GetMedia(m.Id, false).Current;
System.Xml.XPath.XPathNavigator d = n.SelectSingleNode("/node/data[@alias='umbracoFile']");
s=d.InnerXml; // Here is the path


.NET 4.0 Serializing IDictionary

Yes, now we can serializing the object which contain or implement of IDictionay in .NET 4.0.

The different part of code is change to using System.Xaml namespace and the code is more simple, for instance:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {

Now the I have to reconsider the power of the web service…


現在我們可以在.NET4.0 的程式碼中Serializing(序列化)含有IDictionary或是繼承自他的物件.

差異的地方是我們必須引用System.Xaml, 新的序列化服務的寫法也變簡單了, 請參考下面程式碼:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {

嘖嘖嘖..我現在要好好想想web service的威力了….