June 2008 Entries

Windows CE: Starting an Application when the System Boots
You have developed or bought a Windows CE system and developed an Application for it. Now you want to start your application every time the system boots up. Not an unusual need, but the solution will have a lot to do with who you are and what you have to work with. So, who are you? Platform Builder User Since you are using Platform Builder, you have access to the system registry so you can use the HKEY_LOCAL_MACHINE\Init key to start your application. FileSys uses HKEY_LOCAL_MACHINE\Init to find ......

Posted On Monday, June 30, 2008 11:35 PM | Comments (2)

Windows CE: volatile and PBYTE, PDWORD…
Microsoft has been nice enough to supply us with many typedefs that we can use when writing code that should simplify development, especially when our code may be used to target different Microsoft OSs. On the other hand, these typedefs can also cause problems for us when using them to write device drivers. The typedefs that can cause problems are the ones that are pointers, like PBYTE, PDWORD… The reason that they can cause problems is that modifiers like volatile don’t modify in the way that we ......

Posted On Monday, June 30, 2008 10:10 AM | Comments (3)

Platform Builder: It Worked in Debug, but doesn’t in Release
A common problem that developers run into is that when they change the build from debug to release, their application or dll no longer works, or doesn’t run at all. Here are some of the causes that I can think of: 1. The application or driver wasn’t actually in the OS image. This happens a lot because of a handy feature of KITL and the CEShell, which is the Release folder. The Release folder is a folder on the device which is linked to the _FLATRELEASEDIR on your development workstation. When a dll ......

Posted On Friday, June 27, 2008 5:35 PM | Comments (3)

Windows CE: Watching Folders for Changes
It is not uncommon to need to watch a folder for changes to files. It is possible to monitor for changes using FindFirstChangeNotification() and FindNextChangeNotification(). These functions don’t work like FindFirstFile() does, instead FindFirstChangeNotification() returns a HANDLE that can be used in WaitForSingleObject() and WaitForMultipleObjects(). In this post, I will develop a function that will monitor for changes to a list of folders. The function is FolderWatcherThread(). FolderWatcherThread() ......

Posted On Thursday, June 26, 2008 10:38 PM | Comments (3)

Platform Builder: Using Your Developr Batch File
Spell checker is going to hate this post, because the ‘e’ is missing in the folder name Developr. One of the things that you can do to customize the build environment in Platform Builder is to add a batch file to the Developr folder. To use the Developr batch file, you must first create a sub folder named with your system username. The fact is that I am thinking about this right now because my username just changed from beitman to bruce.eitman, so my Developr batch file isn’t working anymore. So ......

Posted On Wednesday, June 25, 2008 10:13 PM | Comments (2)

Windows CE: Displaying Disk Information
To expand on my Serial Debug Port Menu (Windows CE: Serial Debug Menu Summary), I decided to add a Disk Viewer. The Disk Viewer enumerates the disks and partitions to display information about them. This can be a useful tool if you have a headless system and can’t access the Control Panel. The systems doesn’t really have information about disks, instead it has Stores. To find the stores, use FindFirstStore() and FindNextStore() which function much like the other functions that I have already used, ......

Posted On Wednesday, June 25, 2008 9:55 PM | Comments (2)

Windows CE Newsgroups
Update The Windows CE newsgroups have been shut down by Microsoft. This is part of an overall Microsoft strategy to move community from newsgroups to web based forums. The newsgroups have been indexed by Google, so the existing content can and should be searched for answers using http://groups.google.com/ad... Microsoft has replaced the newsgroups with http://social.msdn.microsof... which has forums for OS Development, Managed Application Development ......

Posted On Tuesday, June 24, 2008 4:11 PM

Windows CE: Device Driver Index Greater than 9
Prior to Windows CE 5.0, you could only have up to 10 instances of a driver with the same prefix, like COM. So you could only CreateFile on COM0: through COM9:. Starting with Windows CE 5.0, there is support for BUS mount points ($bus\USBFN_1_0) and device mount points ($device\COM8) which can be used to open a handle to a driver. Platform Builder Help documents these in Device File Names, which isn’t so easy to find. I created a little test to show how to use the different names: void OpenADriver( ......

Posted On Monday, June 23, 2008 1:02 PM | Comments (4)

Microsoft, Me and a Camcorder
Microsoft and I put together a video featuring me to be used at the launch event for Windows CE 6.0. In the end, it wasn't used but it is available from Microsoft. The Bruce Eitman Video doesn't contain any earth shattering information, but you can see who I am. Using some clips from that video plus clips from several other Windows Embedded MVPs, Microsoft also put together a collage video. Meet some of our Embedded MVPs At MEDC 2005, Mike Hall from Microsoft caught me off gaurd and asked me some ......

Posted On Friday, June 20, 2008 11:54 PM

Platform Builder 6.0: Creating a Catalog File
Five years ago, I wrote an article about creating a Catalog file for Windows CE 4.0. How time flies, and how the tools get better as we go. That article turned out to be 10 pages when printed; this one should be much shorter because the tools have become much better. What is the Catalog and why would we want to change it? The Catalog is a collection of components that can be added to your project. These components include OS features, like Internet Explorer, and Board Support Packages (BSP). If you ......

Posted On Friday, June 20, 2008 4:38 PM | Comments (12)

Platform Builder: Fmerge Tips and Tricks
Platform Builder: Fmerge Tips and Tricks Fmerge is a file merge utility that runs when you run makeimg. Fmerge is used to concatenate and process bib, reg, dat, db and nls files. Each file type is handled in a different way. Tip1, check the makeimg output. The makeimg output includes the fmerge command line for each file type. This can be valuable for understanding which file is included when, and the name of the output file that is created. I will leave it to you to review the command line to check ......

Posted On Friday, June 20, 2008 3:00 PM | Comments (0)

Platform Builder: Don’t use Build and Sysgen
Ever since the release of Platform Builder for Windows CE 5.0, there has been an item in the Build OS menu labeled “Build and Sysgen” which causes problems for developers. I believe that this item is very useful for Microsoft’s Software Engineers, but it causes problems for the rest of us. The problem is that Build and Sysgen, especially with the Clean Before Building set, will delete binary files that you don’t have the source to rebuild. Once you have run Build and Sysgen and discover that it created ......

Posted On Thursday, June 19, 2008 12:56 PM | Comments (1)

Platform Builder: Build error “Bad database entry:”
I clicked on the wrong thing this evening while creating a new file using Windows Explorer. Instead I created a new folder with the default name of “New Folder”. Not giving it any thought, I just left the folder where it was. This created an error when I built the code that I was working on. The error was: BUILD: [00:0000000004:ERRORI] Bad database entry: New Folder\ 40000 10 0. This clearly told me that New Folder was creating a problem, and experience tells me that the problem is because there ......

Posted On Tuesday, June 17, 2008 10:49 PM | Comments (0)

Platform Builder: Using Dat Files to Initialize the File System
If you haven’t noticed already, all of the files that you put in the Windows CE OS image end up in the \Windows folder. There is nothing that you can do about that, but you can creates other folders and copy files into those folders using DAT files. DAT files can be somewhat of a mystery because most BSPs don’t do anything with them and the default OSDesigns don’t include anything in the project.dat file. But, the DAT files in the Public folders do include plenty of examples and Platform Builder ......

Posted On Tuesday, June 17, 2008 10:29 PM | Comments (8)

Platform Builder: Using Bib Files to add files to a Windows CE OS Image
Platform Builder Help does a good job of documenting the Binary Image Builder (BIB) files, but finding the documentation can be a challenge and it is filled with a lot of technical detail, but not much how to information. I will try to make that better. Help tells you that there are FILES and MODULES and that your file needs to be added to one of them. The only real guidance that it gives is that a dll in the FILES section will be loaded into Slot 0 taking address space from all processes, and that ......

Posted On Tuesday, June 17, 2008 8:37 PM | Comments (6)

Windows CE: Monitoring for Disk Insertion to add support for Startup folders
Windows CE supports starting applications in the \Startup folder when Windows Explorer starts, but doesn’t automatically run applications on removable media when the media is inserted. It would be nice to have that ability for some devices, although tread lightly with this if security is an issue. The following code example demonstrates how to use the Message Queue Point-to-Point functions and Storage Manager API to detect insertion of removable media and then launch exe files found in a Startup ......

Posted On Friday, June 13, 2008 10:56 PM | Comments (4)

Platform Builder: Why can’t I call the Function in my DLL?
So you added a function to your dll, but your application can’t call the function. This can happen for several reasons: You didn’t build the your source code This is sort of the “did you plug in the device?” kind of question, but worth checking. This can include are you building the right directory? I have been know to work in a folder on someone else’s computer by mistake, but only after working remotely with someone else and looking at files on their computer. You didn’t put the new version of ......

Posted On Friday, June 13, 2008 2:20 PM | Comments (2)

Windows CE: Reading a String from the Registry
I made a change to a string value in the registry recently. That seemed like a harmless thing to do, didn’t it? But, what I did was make the string longer than it was before, again seemed harmless. Harmless until some applications started reading the value into arrays with hard coded length, the problems began. The problem is that RegQueryValueEx() does not have a parameter to indicate the size of the buffer that it will put data into. This means that if the data is bigger than the buffer, RegQueryValueEx() ......

Posted On Wednesday, June 11, 2008 12:48 PM | Comments (5)

Windows CE: How to buy Windows CE or Platform Builder
With so many Microsoft products it is very easy to purchase a license. But how do you by Windows CE? If you want to purchase Windows Vista, you would go to a store (either bricks or clicks) and buy the DVD installation and you are off and running. That just isn’t the way Windows CE works. Windows CE is not a typical off the shelf operating system; it is an operating system for embedded computers. So what is an embedded computer? An embedded computer is a special purpose computer that has custom software ......

Posted On Tuesday, June 10, 2008 9:28 PM | Comments (1)

Windows CE: Serial Debug Menu Summary
This is a summary of links to my post that describe creating a serial debug port menu for a Windows CE device. Sure, many of you won’t actually use the debug menu, but this includes some sample code that you may be interested in. Windows CE: Using the debug serial port for input is a getting started by reading input from the serial debug port. Windows CE: Displaying a simple menu driven app using serial debug shows how to display a menu based on an array of strings and wait for user input from the ......

Posted On Tuesday, June 10, 2008 1:19 AM | Comments (0)

Windows CE: Listing Running Drivers
I recently posted a sample stream interface driver (Windows CE: A Stream Interface Driver Shell) and claimed that I included enough to cause the driver to be loaded by the device manager. The following code is how I know that it loaded. This code enumerates the running drivers using FindFirstDevice() and FindNextDevice() which are included in the device manager functions. There are several options for enumerating the drivers, this example uses DeviceSearchByLegacyName. I include this function in ......

Posted On Tuesday, June 10, 2008 1:03 AM | Comments (2)

Windows CE: A Stream Interface Driver Shell
Note: In Windows CE: Stream Interface Driver Power Management I have included a download of the source code for this driver. I thought that it might be useful to have a shell of a stream interface driver that I could use to start developing a driver from. I can’t believe that I never created this before, but here it is. I called this driver “DriverShell” because that is all that it is, a shell of a driver. This is a very basic starting point for creating a new driver. I have tested that this driver ......

Posted On Monday, June 9, 2008 5:58 PM | Comments (30)

Platform Builder: Summary of Building Windows CE
This is a summary of the articles that I have written that discuss the Platform Builder command line build tools. Using the Command Line Platform Builder: Build Tools Intro This is an introduction to the articles about using the command line build tools. Platform Builder: Build Tools, Opening a Build Window This discusses ways to open a command windows with the environment set up to build a project. Platform Builder: Using BldDemo This discusses using BldDemo.bat to build a project. Platform Builder: ......

Posted On Friday, June 6, 2008 4:44 PM | Comments (4)

Platform Builder: Getting from BSP Source Code Change to Test Quickly
Anyone who has used Platform Builder knows that running Sysgen can take 15 minutes, or even more to build the OS. That kind of delay between changing code and testing can be crippling to your development, and can cost your company hundreds or even thousands of dollars a day in lost productivity. There must be a better way. In fact, there are several options available. The following will discuss several of these options. FAST: Build and Makeimg from the Command Line The option that I use most, primarily ......

Posted On Friday, June 6, 2008 9:14 AM | Comments (4)

Platform Builder: Building a Bootloader
Building a bootloader isn't much different than building a driver or an application. In fact, if you have already built your project more than likely your bootloader has already been built. But what if you want to make a change to the bootloader? Then knowing how to build it, and more important what happens when you build it, will help get from changing code to testing faster. The first step is to find the source code. The source code may be in different places depending on the version of Windows ......

Posted On Thursday, June 5, 2008 4:39 PM | Comments (0)

Windows CE: GetAdaptersInfo() handling when no Adapters Exist
I thought that I would experiment with GetAdaptersInfo() yesterday (this is GeeksWithBlogs!) Being lazy, I googled to find example code to start with, and found GetAdaptersInfo Function on MSDN . This certainly was a good starting point, but I soon found a problem. As it turns out, the day before I had been working on Platform Builder: Find the Source of a Data Abort; an Example where I purposely added a Data Abort to my Ethernet driver. As a result, I didn't have any Ethernet adapters to get information ......

Posted On Wednesday, June 4, 2008 11:10 PM | Comments (0)

Platform Builder: Managing the Registry
The Registry is an important part of Windows CE and allows you to manage many parts of the system's behavior. You have two registry files available to you to use for managing the registry in your system; platform.reg and project.reg. Platform.reg is used to make changes that apply to your BSP, if you are developing a BSP Project.reg is used to make changes that apply to your project You can use these files to add new registry keys and values, you can change existing values and you can delete keys ......

Posted On Wednesday, June 4, 2008 10:42 PM | Comments (9)

Platform Builder: When to do a clean build?
The rule of thumb, and this applies to any OS and compiler, when using make (or nmake) is that if you change a file that is being built then you can generally just build. But if you are changing something that make doesn't do a dependency check on, like a makefile or an environment variable, then you need to do a clean build. The reason is that make does dependency checks based on file timestamps to decide what to rebuild. Changing environment variables does not change timestamps. Selecting different ......

Posted On Tuesday, June 3, 2008 3:59 PM | Comments (0)

Platform Builder: Find the Source of a Data Abort; an Example
Previously I posted instructions for finding the source of a data abort, see Windows CE: Finding the cause of a Data Abort. This will walk through those steps to find the source in a real application for. This is specific to Windows CE and later. I have this data abort: AKY=00000005 PC=02c138ac(lan91c111.dll+0... RA=02c138a8(lan91c111.dll+0... BVA=06000000 FSR=00000007 From this, I can see that it is in lan91c111.dll. Lan91c111.dll is my Ethernet driver. I was just making changes to ......

Posted On Monday, June 2, 2008 5:56 PM | Comments (20)