Note: this entry has moved.
也许你可能什么时候会把你BLOG的密码给忘记了,不用抓狂,如果你曾经配置了Live Writer来连接你的BLOG,那么你还是有机会找回密码的。用这样一段代码就可以找到你的密码:
using System; |
using Microsoft.Win32; |
using WindowsLive.Writer.BlogClient; |
using WindowsLive.Writer.CoreServices.Settings; |
namespace ConsoleApplication1 |
{ |
class Program |
{ |
static void Main(string[] args) |
{ |
RegistrySettingsPersister persister = |
new RegistrySettingsPersister(Registry.CurrentUser, |
@"Software/Microsoft/Windows Live/Writer/Weblogs"); |
string[] names = persister.GetSubSettings(); |
for(int i = 0; i < names.Length; i++) |
{ |
ISettingsPersister blogPersister = persister.GetSubSettings(names[i]); |
SettingsPersisterHelper settings = new SettingsPersisterHelper(blogPersister); |
CredentialsDomain domain = new CredentialsDomain("name", "description", null, null); |
BlogCredentials creds = new BlogCredentials(settings, domain); |
string blogName = blogPersister.Get("BlogName") as string; |
Console.WriteLine("Blogname: {0}, Username: {1}, Password: {2}", |
blogName, creds.Username, creds.Password); |
} |
} |
} |
} |
可执行程序在这里下载,程序在Live Writer build 12.x下测试通过。