2011年9月29日 星期四

ChkInf使用方法

DDK中提供了ChkInf的Tool幫助開發人員檢查Inf檔有無問題
但是要使用該Tool時卻不知道該如何著手!
根據DDK的說明文件,開啟一個command視窗來執行ChkInf.bat時,卻發生以下的錯誤:
'perl.exe'不是內部或外部命令、可執行的程式或批次檔

經過一番研究後終於找到該如何使用該Tool...(DDK的Help寫得真是....好)
正確的使用方法是從程式集中打開一個Build Environment
例如我的開發環境是WinXP,則打開WinXP下的Build Environment

再進入 %DDKRoot%\Tools\Chkinf 的資料夾下,執行ChkInf.bat即可
執行完之後,ChkInf分析的結果會存到 %DDKRoot%\Tools\Chkinf\htm 的資料夾下
以下為ChkInf的參數說明:

Syntax

chkinf {INFFile [INFFile...] | Directory} [/L LogFile] [/B] [/LO] [/DC Options]

Parameters

INFFilet
Specifies the fully qualified path and file names of one or more INF files. ChkINF verifies the specified files. You can use the wildcard character (*) to specify multiple files, for example, *net.inf.
Directory
Specifies a directory that contain INF Files. ChkINF examines all INF files in the directory. You cannot use the wildcard character (*) in a directory name.
/L TextFile
Creates a results file in text format, in addition to the HTML files. The text file includes results for all INF files that were validated. TextFile specifies a path and file name for the resulting file. There is no default name or location. If you do not specify a file name, ChkINF does not create a text file.If you do not specify a path, ChkINF creates the text file in the current directory, not in the htm subdirectory with its other output files.
/B
Displays the results when command completes. If ChkINF is validating one INF file, ChkINF displays the results for that INF file. If ChkINF is validating more than one file, it displays the summary of results.
/A
Overwrites the results files from previous runs without prompting the user.
/LO
Determines whether the INF file conforms to the layout rules defined in the layout.inf file. This test is designed for printer INF files and files that are included in Windows.
/DC Options
Specifies the device class-specific options that ChkINF should use when checking INF files. At present, the only supported option is NOFAX, which instructs ChkINF not to check any Fax keys present in modem INF files.

PS:不需要到www.perl.org download Perl來安裝喔,安裝之後還是不能使用ChkInf的...^^

fastinst工作原理

在使用DDK開發USB Driver的安裝程式時,遇上了一個問題
當使用
UpdateDriverForPlugAndPlayDevices這個API來實作時
遇到了一個問題,這個API必須在Device連接上系統時才能將Driver安裝上去!
但是因為產品規格限制,必須開發出Device未連接系統也可以安裝Driver的功能!

請教過一些前輩的開發經驗後,發現Walter Oney在Programming the Microsoft Windows Driver Model書中有一個tool為fastinst,參考該sample code即可了解如何完成這樣的功能。
該Tool的工作原理,其實說穿了非常的簡單~~
在使用UpdateDriverForPlugAndPlayDevices這個API安裝Driver之前
利用
SetupDiCallClassInstaller在系統內register一個虛擬的Device node.
安裝完Driver之後,再ungister該Device node(一樣是用
SetupDiCallClassInstaller這個API)。
利用以上的一點小技巧,即可完成不用插入裝置也可以安裝Driver的功能囉~

DPInst說明

在Microsoft提供的DDK開發工具中,包含了一個好用的工具:驅動程式套件安裝程式 (DPInst)
DPInst是驅動程式安裝架構DIFx(Driver Install Frameworks) 所提供的工具之ㄧ,DIFx提供了基礎架構和工具來簡化開發人員和使用者的裝置與驅動程式安裝。
詳細資訊請參考官方所提供的說明:
http://support.microsoft.com/kb/910189/zh-tw

這個工具的設定,是搜尋目前的路徑、或是在指定的路徑下,嘗試安裝所有找到的驅動程式。
在搜尋相關資訊時,找到某篇部落格的文章提到如何利用InstallShield實作WDM的驅動程式安裝包,內容就是利用DPInst這個工具來實作的,寫得非常地詳盡,有需要的朋友可以拜讀一下這位賢拜的大作:
http://blog.xuite.net/kyanite0909/techshare/25750034#16530720

但是要使用該工具時,必須先將裝置接上系統

DPInst的英文參數說明:
Usage: DPInst.exe [/U INF-file][/S | /Q][/LM][/P][/F][/SH][/SA][/A][/PATH Path]
[/EL][/L LanguageID][/C][/D][/LogTitle Title][/SW][/? | /h | /help]

 /U path to INF file
 Uninstall a driver package (INF-file).
 /S | /Q Silent (Quiet) mode. Suppresses the Device Installation
 Wizard and any dialogs popped-up by the operating system.
 /LM Legacy mode. Accepts unsigned driver packages and packages with
 missing files. These packages won't install on the latest
 version of Windows.
 /P Prompt if the driver package to be installed is not better
 than the current one.
 /F Force install inf the driver package is not better than the
 current one.
 /SH Scans hardware for matching devices and only copies and installs
 those drivers for which a device is present. Only valid for
 Plug and Play drivers.
 /SA Suppress the Add/Remove Programs entry normally created for
 each driver package.
 /A Install all or none.
 /PATH Path
 Search for driver packages under the given path.
 /EL Enables all languages not explicitly listed in the XML file.
 /L LanguageID
 Tries to use the given language in all UI.
 Useful for localization tests.
 /SE Suppress the EULA.
 /C Dump logging output to attached Console (Windows XP and above).
 /D Delete driver binaries on uninstall.
 /SW Suppresses the Device Installation Wizard, the operating system
 might still pop-up user dialogs.
 /? | /h | /help
 Shows this help.




Build 64位元作業系統的應用程式

近來以VC8在開發64位元作業系統的應用程式時遇到了一些問題
問題描述與解決方法如下:
(1) Build出來的Application 無法在64位元的作業系統執行,出現"The application has failed to start because the application configuration is incorrect."


解決方法:更改Project Property為Use MFC in a Static Library.
Project → Property → Configuration Properties → General → Project Defaults → Use of MFC → Use MFC in a Static Library. 如下圖

(2) 執行應用程式時出現 "the application was unable to start correctly (oxc0150002)" 的訊息,這是因為以VC2005或VC2008開發的應用程式,所需的Library未正確地安裝到系統。
只要到Microsoft下載對應的redistributable package,安裝到系統即可。
For VC2005 x86:
Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)

For VC2005 x64:
Microsoft Visual C++ 2005 SP1 Redistributable Package (x64)
For VC2008 x86:
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)
For VC2008 x64:
Microsoft Visual C++ 2008 SP1 Redistributable Package (x64)

在Vista與Win7 x64上,原本安裝的VC redistributable Package為版本2.0.50727.762,但安裝此版本仍無法讓程式正常啟動,而下載SP1的6.0.3790.0安裝之後即解決問題。

查詢系統錯誤

應該有些人在安裝驅動程式時有過這樣的經驗
驅動程式安裝完之後,系統顯示:
這個裝置無法啟動,代碼10
並且在裝置管理員出現黃色的驚嘆號~

根據Microsoft的說明,可啟動疑難排解精靈來查詢處理方法:
說明 Microsoft Windows XP Professional 的「裝置管理員」所產生的錯誤碼

而另一篇技術說明文章則教導如何使用事件檢視器來查詢問題發生的原因:
如何疑難排解 Zune 裝置錯誤 Windows 裝置管理員 」 中
簡單地說,可以經由以下兩個方法開啟事件檢視器

  1. 開始→執行,輸入eventvwr.exe

  2. 在我的電腦按右鍵→管理→系統工具→事件檢視器
再從系統的錯誤中查出對應的錯誤碼與資訊:

將所取得的錯誤事件ID輸入事件和錯誤訊息中心中查詢即可查詢到進一步的錯誤資訊囉:
事件和錯誤訊息中心

MySql Workbench 建表 - 欄位屬性縮寫意義


以下縮寫是以MySQL Workbench建立資料欄位的時候,可設定的一些欄位屬性:
  • PK: Belongs to primary key
  • NN: Not null
  • UQ: Unique index
  • BIN: Is binary column
  • UN: Unsigned data type
  • ZF: Fill up values for that column with 0's if it is numeric.
  • AI: Auto Incremental.