懶懶低~~~~

1130143261.jpg
(圖片來自: 彎彎)

最近似乎得了嗜睡症~~~

只要週末在家~就狂睡~

這個周末+228假期~~平均每天以14個小時在睡

是平常太累了嗎??

用XMLSPY與VS2005來做XML 編輯與偵錯

在軟體開發的過程中,對於一些需要的儲存資料,往往一般工程師都會使用INI檔來做為存取的要求。但是隨著資料量的增大、對於資料搜尋程度的渴望與日俱增。所以現在的許多APP開發上都會使用到XML來作為儲存資料與處理資料的中介。

但是隨著XML發展來的XPATHXSLTXQUERY種種多的語法來說,也是會讓人一下子無法找到任何的頭緒。

今天在看MSDN的雜誌的時候看到有關於Neetu Rajpal寫到關於An Introduction to the XML Tools in Visual Studio 2005,就直接拿手邊的VS2005來測試一下,果然相當的好用,對於XML的編輯上、使用XSLT來做搜尋的時候,更可以加上偵錯與逐步執行的功能,真是相當的人性化呢~~~~

VS2005_XML.JPG
(VS2005 裡面編輯XML,XSLT的畫面)

當然有許多家的業者也有許多相當好的XML編輯軟體可以使用,ALTOVA所研發的XMLSPY,如果只用到XMLSPY功能也就相當齊全,不過倒是用不太習慣就對了,不過慢慢適應總是會有所成長才對~~~

XML_SPY.JPG
( ALTOVAXMLSPY)

“Windows Service” and “Registry key”

WindowsService (WinCE).JPG

There are something we should keep in mind when we tried to write a Windows Service. The most important is the “Registry Key”.

In Windows programming, we usually use registry key to setting some value for difference user. Regstry key control become more and more in your code, and we also usually  read the specific user in “HKEY_CURRENT_USER” **first then open generic “HKEY_LOCAL_MACHINE” .**

Here comes the problem, According this article(Services and the Registry) in MSDN. We should not use “HKEY_CURRENT_USER” **to retrival current user’s registry key value. Because Windows Services always startup before user login. It may happen some error or loading the wrong setting profile. If you still insist on using the current user registry key setting, please refer ”RegOpenCurrentUser”. In my experience use “RegQueryValueEx” with “HKEY_CURRENT_USER”** will retrival the RootUser’s setting. It make me confuse.

So the better way the use registry key in Windows Service is handle the “HKEY_LOCAL_MACHINE” **rather than “HKEY_CURRENT_USER”.**

A Quick note to “Windows Service”

WindowsService (WinCE).JPG

A simple note from “Write Pure Windows Service” and “How to debug Windows Service”.

Write “Windows Service”

Windows Service is kind of application but it will start when system startup. Windows service will triggerd by “SMC”(System Managed Controller). There is some important note from my writing windows service experience.

  1. **Register your service:
    **What ever your application is big or small. You must register them to SMC before you use it. Please reference ::OpenSCManager() and ::CreateService().
    For more detail please reference Writing a Service Program’s main Function

  2. Start a “Windows Service”.
    You can not startup a windows service via any debugger, you need to startup it on SMC. The SMC will use ::StartServiceCtrlDispatcher to start service and wait for the call back signal “SERVICE_RUNNING”. If you can not startup windows service normally, please let the Service_Status call back and tried to figurate out the root cause. For more detail please refer to Installing a Service

  3. Stop a Windows Service
    When you tried to close a windows service from SMC.The handler will receive a “SERVICE_CONTROL_STOP” from system. Your program have to pass “SERVICE_STOP_PENDING” and call RevokeClassObjects() . For more detail please refer to Stopping a Service.

Debugging “Windows Service”

There are two “easy” ways to debug your Windows service.

  1. Attach Windows service by debugger:
    In VC6 “Build”–> “Start Debug” –>”Attach a process” to point out your service it will use debugger to debug the service.

  2. “Debugging Windows Service”
    use “DebugBreak();”. it will pop up the Window and allow you to debug into Windows Service(You must install VC6 or higher version).

  3. For more detail, please refer this address(How to debug Windows services).

At finally, there is a best practice for you.

2006-03-20:(Update)

Please note:

  1. VC7 or VC8 may have some problem when attach the VC6 debug version. (I think it is the pdb doesn’t match).
  2. To attach the thread. you may need to turn on the “Show system process”, it will show the Windows Service process.

2006-04-12:(Update)

Download Beeper Service Simple Code

本站開始檔blogspot的留言

Blogger

由於來自於blogspot.com的廣告實在太多,不知道是不是她們自己的問題,還是廣告商的利害~~ 決定要檔這整個網域的留言~~~ 若是從這些網站來的~~ 請加上空白

勇者鬥惡龍~ 裝備篇

《勇者斗恶龙II》对应手机追加新型号

之前去日本北海道的時候,去電玩賣場的玩具部看到的。雖然沒有買到羅德系列的裝備~~ 但是卻也買了兩個很漂亮的武器~~

IMG_0046.JPG

  IMG_0047.JPG

IMG_0051.JPG

IMG_0052.JPG

IMG_0053.JPG

IMG_0057.JPG

IMG_0059.JPG

IMG_0060.JPG