人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

December 21, 2006

WPF之窗体模型

Filed under: Windows platform

编程
1. MyApp.xaml
Define Start up window(StartupUri) for the application
<Application StartupUri = “MyWindow.xaml”/>

2.MyWindow.xaml

<Window x:Class=”MyWindow” Width=”300″ Height=”200″ Title=”">
<Button Click=”ButtonClick”>
</Button>
</Window>

3.MyWindow.cs

4.myProj.csproj

5.msbuild myProj.csproj

编译过程:
Layout,Control的设定被转化为 BAML(Binary App Markup Language), 再嵌入到resources中
BAML+ C# -> exe

实验1: 查看obj目录,包含编译的中间结果:
MyWindow.cs
MyWindow.g.cs
MyWindow.baml

实验2:查看msbuild 编译时在控制台的输出

执行流程:
SourceInitialized
Activated
Loaded
ContentRendered
Deactivated/Acrivated
Closing
Closed

交互
WindowsFormsHost(将windows control放到wpf form)
ElementHost(将wpf control 放到 windows from)
HwndHost, HwndSource(与Win32和MFC窗体/控件进行交互)

Reference
www.techjie.com

December 19, 2006

Install Firefox2.0 in Fedora C6

Filed under: 使用技巧

I want to upgrage the FireFox 1.5 come with FC6 to FireFox 2.0.
But when I run the firefox-2.0-1.fc6.remi.i386.rpm, an error message popup:
“Missing Dependency: gecko-libs = 1.8.0.8 is needed by package yelp”

Where could I get gecko-libs? The answer is FireFox-2.0-1.fc6.remi.i386.rpm!
The rpm of FireFox 2.0 contains gecko-libs.

So I try to uninstall FireFox 1.5 before install FireFox 2.0.
rpm -e firefox
Another error occurred: “Failed dependencies……”
Then, I used
rpm -e –nodeps firefox, unstalling was successful!

After that, I run rpm -ivh FireFox-2.0-1.fc6.remi.i386.rpm, successful!

Linux Services

Filed under: 使用技巧

1.Start service:
service smb start

2.Stop service
service yum-updatesd stop

2.Restart service
service smb restart

3.List all service
service –status-all

4.Service auto start
ntsysv

5.Services:
yum-updatesd Auto update

6.GUI Setting:
System->Administration->Server Settings->Services

December 13, 2006

VMPlayer 中的Fedora不能调整分辨率

Filed under: 使用技巧

Soultion:
Modify /etc/X11/xorg.conf

# Xorg configuration created by pyxf86config
Section “ServerLayout”
Identifier “Default Layout”
Screen 0 “Screen0″ 0 0
InputDevice “Keyboard0″ “CoreKeyboard”
EndSection

Section “Monitor”
Identifier “Monitor0″
HorizSync 1.0 - 10000.0
VertRefresh 1.0 - 10000.0
EndSection

Section “InputDevice”
Identifier “Keyboard0″
Driver “kbd”
Option “XkbModel” “pc105″
Option “XkbLayout” “us”
EndSection

Section “Device”
Identifier “Videocard0″
Driver “vmware”
EndSection

Section “Screen”
Identifier “Screen0″
Device “Videocard0″
Monitor “Monitor0″
DefaultDepth 24
SubSection “Display”
Depth 24
Modes “1152x864″ “1024x768″ “800x600″
EndSubSection
EndSection

我的Host机器分辨率为1280x1024, 为了不让VMPlayer产生滚动条,1152x864是fedora的最大分辨率.

December 10, 2006

The Sysinternals Video Library-Windows Crash Dump & Hang Analysis

Filed under: Uncategorized

–Why does winows crash?
Sth’s wrong in kernel-mode
Unhandled exception
OS or driver detected server inconsistency
Invalid memory references
Hardware error

–Crach Dump Types and Mechanisms
How to config:
My Computer->Property->Advanced->Startup and Recovery->Setting

Crash Dump Types:
Complete: default for server, all of RAM
Kernel memory dump: OS/Driver memory, No process memory, default for vista
Small: Default for XP

Minidumps:
Contents: Bugcheck code, parameters, List of drivers, mini info on current process
Location: %windir%\minidump

What initiates a Crash?
OS or driver detects fatal condition
Call KeBugCheckEx()

Bugcheck code(Stop code)
Documented in WinDBG’s Help file(Debugging Techniques->Bug Checks).

Crash Steps:
Turn off interrupts
Tells other CPUs to stop
Paints the blue screen
If dump configured, records in paging file

Analysis Tools
WinDBG
KD

Kernel image: Ntoskrnl.exe Ntoskrnal.pdb

Key internal concepts:
process
thread
memory protection
interrupt request level(IRQL)

Config the debug tool to download system symbol from symbol server.
You can set symbol directories through File->Symbol File Path,
Eg,SRV*c:\websymbols*http://msdl.microsoft.com/download/symbols
or using .sympath from the WinDbg command window
Symchk.exe : force symbol download.

The Sysinternals Video Library-Tour of the Sysinternals Tools

Filed under: Web cast学习

The Sysinternals Video Library (http://www.solsem.com/videolibrary.html)]
Tour of the Sysinternals Tools
The history of Sysinternals, an overview of the site, and a fast paced
tour of the major tools

–History:
*1996: ntinternals.com
10 tools
1500 visitors/day
*2006: sysinternals.com
100 tools
80000 visitors/day

–Tools
Process Explorer(Thread details, Handle view, dll view)

Handle (lists hanles)
ListDlls (lists Dlls)

PsList (Show information about processes and threads)
PsKill (Kill processes)
PsSuspend (Suspedn processes)
PsExec (execute a command local/remote)
psexec \\remote cmd
PsService

PsInfo
PsLogList
PsLoggeOn

BgInfo
ProcFeatures (Processor hardware features)
LoadOrders (load order of drivers and services)

PendMoves (list pending file operations)
Portmon (serial port monitor)

DebugView
Winobj
LiveKd

Filemon
Diskmon
DiskView (Graphical disk sector utility )
Du (View disk usage by directory )

Contig (defragment your frequently used file)
PageDefrag
Junction (Create Win2K NTFS symbolic links )
Sync(Flush cached data to disk)

Strings (dump strings in any file)

Regmon
Regjump

Autoruns
Sigcheck
RootkitRevealer

AccessEnum
ShareEnum
SDelete
NewSID

TCPView
Whois(See who owns an Internet address)
AdRestore (Undelete Server 2003 Active Directory objects)

December 5, 2006

[HTML] Disabled control can’t be submited!

Filed under: ASP.NET

Forms in HTML documents.
http://www.w3.org/TR/html4/interact/forms.html#adef-readonly
17.12 Disabled and read-only controls
17.13.2 Successful controls

TextBox can be used with readonly attribute.
Checkbox will be used with javeScript “return false;” to simulate the readonly state.

December 4, 2006

Application_Start 中的断点

Filed under: ASP.NET

我在Application_Start中加了一个断点,第一次使用f5运行程序,断点可以工作,
然后终止程序,再运行,断点就不工作了,重起IIS,断点又可以工作,
原因不明.

Gadget开发入门

Filed under: Windows platform

http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx

–Where is the Side bar
C:\Programe Files\Windows SideBar\
SideBar的主程序以及公用的Gadget

“%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets”
此处保存的是某个特定用户的Gadget.

–Run the Sider bar
Start -> All Programs -> Accessories

在vista的help中,查找 Windows Sidebar: frequently asked questions
How do I open Sidebar?
Click to open Windows Sidebar.对应的link为:
<a class=”shellExecuteLink” href=”shortcut:&quot;%25programfiles%25\windows sidebar\sidebar.exe&quot;”
title=”Click to open Windows Sidebar”>
<img src=”mshelp://help/?id=Microsoft.Windows.Resources.ShellExecuteTopicIcon”>
Click to open <span class=”notLocalizable”>Windows</span> Sidebar.
</a>
href=”shortcut:”%programfiles%\… “”这种写法我还是首次注意到.

–Mechanism of Sidebar and Gadget
Gadget由HTML, JavaScript,CSS,图片,资源组成, 通过调用Sidebar提供的API和系统中的ActiveX对象来完成操作.
常用到的ActiveX:
JScripting.FileSystemObject访问文件系统,
Microsoft.XmlDom分析XML文件,
Microsoft.XMLHTTP调用Web Service

Gadget本身是zip或cab格式,如果使用cab格式,需要进行数字签名, VS2005提供了数字签名工具Signtool.exe.

Gadget在其安全配置上,与普通的Web网页有很多不同点。
1. Gadget可以创建任何已安装的ActiveX对象的实例,因为其被配置为”可以初始化并且脚本访问未被标记为安全的ActiveX”。
2. Gadget也可以访问跨域的数据源,因为只有将不同位置的数据进行相应的集成,Gadget对于开发人员和最终用户才有意义。
3. 重要!!一个在Microsoft Gadget Gallery中发布的Gadget只能使用系统已有的ActiveX,禁止下载任何新的ActiveX控件,
无论这个ActiveX控件是签名或者未签名的。

注意:一个Gadget可以有多个实例同时运行.

–文件组成:
Gadget 所在folder的名称必须以.gadget结尾. 比如HelloWorld.gadget
* 我写了一个gadget,目录命名为为Mailsnatcher.gadget,无法从Gadget Gallery中看到,
改为eMailsnatcher.gadget,就可以看到了,原因不明.

以Clock为例, Clock位于%programfiles%\Windows\Gadgets\Clock.Gadget
主程序位于en-US下,可见各个语言对应的主程序可以不同.
en-US\中的gadget.xml是最关键的部分,定义了整个Gadget的信息以及用到的资源.
.Html用于定义gadget的UI,行为

gadget.xml gadget 的manifest, 只能取gadget.xml这个名字

常用的资源有:
icon, gadget.xml中<icons>中指定,用于在Gadget Gallery中显示.
defaultImage , gadget.xml中<defaultImage> 中指定,用于在拖动时显示.
logo, gadget.xml中<logo >中指定,用于在拖动时显示.用于在Gadget Gallery中显示详细信息.
这3个资源的路径都是相对于.gadget目录的.

–开发要点:
无IDE,不能所见即所得; 无法进行Debug,只能写Log来Trace;

–Sample
在”%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets”下
生成目录: HelloWorld.gadget

在HelloWorld.gadget下生成文件gadget.xml
<?xml version=”1.0″ encoding=”utf-8″ ?>
<gadget>
<name>First Gadget!</name>
<namespace>Example.You</namespace>
<version>1.0</version>
<author name=”Aloneplayer”>
<info url=”" />
</author>
<copyright>2006</copyright>
<description>My first gadget</description>
<hosts>
<host name=”sidebar”>
<base type=”HTML” apiVersion=”1.0.0″ src=”HelloWorld.html” />
<permissions>full</permissions>
<platform minPlatformVersion=”0.3″ />
</host>
</hosts>
</gadget>

在HelloWorld.gadget下生成文件HelloWorld.html
<html>
<head>
<title>Hello, World!</title>
<style>
body {
width:130;
height:50;
}
</style>
</head>
<body>
<span id=”gadgetContent” style=”font-family: Tahoma; font-size: 10pt;”>Hello, World!</span>
</body>
</html>

此时,就可以点击Sider bar上的”+”呼出Gadget Gallery,可以看到一个以gadget.xml中<name>为命名的
gadget.

修改HelloWorld.html,使用背景:
<style>
body {
width:130;
height:50;
background: url(’Background.png’);
padding-top: 5px;
}
</style>

使用API:
<html>
<head>
<title>Hello, World!</title>
<style>
body{
width:130;
height:50;
background: url(’Background.png’); }
padding-top: 5px;
</style>
<script>
var variableName = “ProgramFiles”;
function setContentText() {
gadgetContent.innerText = System.Environment.getEnvironmentVariable(variableName);
}
</script>
</head>
<body onload=”setContentText()”>
<span id=”gadgetContent” style=”font-family: Tahoma; font-size: 10pt;”>Hello, World!</span>
</body>
</html>

添加Setting,此刻可以看到Gadget上会出现一个扳手状的buttong,同时context menu上也会出现”options”
用于进行setting
<html>
<head>
<style>
body{
width:250;
height:75;
}
</style>
<script>
function init()
{
var currentSetting = System.Gadget.Settings.read(”variableName”);
if (currentSetting != “”)
envVar.innerText = currentSetting;
}

System.Gadget.onSettingsClosing = SettingsClosing;
function SettingsClosing(event)
{
if (event.closeAction == event.Action.commit)
{
variableName = envVar.value;
System.Gadget.Settings.write(”variableName”, variableName);
}

event.cancel = false;
}
</script>
</head>
<body onload=”init()”>
<span id=”mySpan” style=”font-family: Tahoma; font-size: 10pt;”>
Environment Variable:<br>
<input type=”text” id=”envVar” length=”40″>
</span>
</body>
</html>

–发布:
把所有的文件做成一个zip包或cab包,把包的后缀改成.gadget,双击.gadget,就可以安装这个
gadget.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham