Chapter 7. Operating System Access
Some things are not easily done in Visual Basic, and this is especially true when using VB on the Palm. This chapter and the following chapters show how to program around the limits of the VB language, either by using the resources of the Palm operating system or by developing reusable components.
You will recall from our discussion in Chapter 3 that AppForge provides many Palm OS features as a library of functions. In this chapter, we’ll look at how to call into the operating system to access features not exposed by the standard AppForge library. And we’ll build an extended example that uses encryption features in the Palm operating system to secure application data or database records from prying eyes.
In VB for the Windows desktop, accessing OS functions is straightforward once you know a few simple facts about the subroutine or function you want to call. The information needed—the function name and result type, the DLL in which the function resides, and the number and type of any arguments—is easily obtained from the Microsoft Platform SDK.
For example, to retrieve the name of a logged-on Windows user, you might add the following declaration to any VB form or module:
Declare Function GetUserName Lib "advapi32.dll" (ByVal Buf as String,_ ByRef Size as Long) as Long
Now, it is possible to call the function as if it were a built-in VB function. There are some issues, such as passing strings and memory between VB and C/C++, but these are generally ...
Get Programming Visual Basic for the Palm OS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.