Email:   
Home
In This Issue
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.
PROGRAMMING POWER
Freeing up DLLs, avoiding suspend mode, and listbox tricks
By Andrew Tucker

Welcome to the first installment of the Windows CE Power Magazine Programming Power column! Each month we'll address tough issues about writing software for Windows CE and provide solutions that usually include a code snippet or two.

This month, we've selected issues that are common stumbling blocks. But what will really make this column work is if we answer questions from those of you fighting daily battles in the trenches. Want to know how to workaround an API that's not available on Windows CE? Need help determining if your code will work on both a Palm-sized PC and a H/PC Pro? Send us email at poweranswers@bsquare.com, including code where appropriate, and we'll try our hardest to find a resolution for you.

Most of the topics we'll cover are for those of you using the Visual C++ Toolkit for Windows CE, but we'll address occasional questions about Visual Basic for Windows CE and other development tools as well. Without further ado, let's jump into this month's questions.

How come calling CoFreeUnusedLibraries doesn't seem to release any of my DLLs, even though there are no outstanding COM objects?
Using memory efficiently is always a good idea for any software system, but it's paramount for most Windows CE applications. Since embedded devices don't have the seemingly endless RAM and hard drive space of desktop systems, a memory hogging application can quickly have a dramatic affect on system performance.

The designers of COM had this issue in mind when they came up with the CoFreeUnusedLibraries API. Calling this function occasionally, usually in a message loop or when the system is idle, will release any DLLs that don't have any COM objects currently dependent on them. A DLL indicates a willingness to be unloaded by returning S_OK from its exported DllCanUnloadNow function. On Windows CE however, a return value of S_OK doesn't result in the DLL being freed up immediately.

Once a DLL has indicated that it's able to be unloaded, CoFreeUnusedLibraries just captures the current system time. On subsequent calls to CoFreeUnusedLibraries if DllCanUnloadNow still returns S_OK and a specified time period has elapsed, then the DLL is actually freed. If during the time period DllCanUnloadNow returns S_FALSE, the clock is reset and the whole process starts over.

The default time period that CoFreeUnusedLibraries waits is ten minutes -- much longer than the patience of most developers that are trying to test their DllCanUnloadNow implementation.





[ Next ]

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

-- Advertisement --

SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:

  • Fully validated
  • Up to 256-bit encryption
  • Up to 10 years validity
  • Stringent authentication
  • Around-the-clock customer support

Build trust. Protect your customers. Grow your online business.

Tap here now and be IronClad with SSL tonight.

Copyright © 1999-2008, ZATZ Publishing. All rights reserved worldwide.
Editor's Login