Monday, April 2, 2007

XPe tip #12: SetupAPI - nothing is more helpful than logging!

To continue my previous post to this blog I want to mention another great tool that is always available to us, XPe developers, on target systems. When I say always I assume the right components are included - kernel and "Primitive: Setupapi". But you can barely find an XPe image that doesn't have the last component added.

Anyway, what is the SetupAPI log? It is a set of API functions that a setup application calls to perform application installation operations. The functions are available to develop a setup application that can install any type of application, from driver to user mode app. MSDN has a big and nice section dedicated to Setup API.

Since most of the issues we are fighting with on XPe are often related to components we ain't provided with source code for, especially third party drivers, having at least a way to analyze failures of those components with the logging tool is a great thing.

Anyway, some quick details for those who never dealt with Setu API logs. By Default the log is centrally located under %windir% folder and called setupapi.log. There are some registry entries to set up and configure how you want the logging to be performed. E.g., the most important value for us is logging level. Often the default log level is not enough to find out what's missing or went wrong with the image. So, increasing the level may help to get more information about the failures and possible get on the right track fixing them.

Here is the instructions on how you increase the log level. SourceQuest also has a freeware GUI utility that allows you to modify SetupAPI configuration parameters without remembering all the configuration registry paths. That utility - suplog.exe, which is already there and available for download, aims to simplify the capture and display of SetupAPI logs. BTW, changing most of the settings is dynamic and will be picked up by the new loaded instance of the app being installed and analyzed.

Quick note here. There is a very useful option for SetupAPI available that allows you to direct the logging to debugger output that you can easy capture with DebugView tool from sysinternals.com. It gives you a nice control over the log for your only component that you are trying to install at run time.

No comments: