Index   Commented   Search   About

Opening the Pen Driver

Before sending a driver a message, an application must first obtain a handle to the driver with the Windows OpenDriver function. The following code demonstrates this:

HDRVR hDrvPen;

.

.

.

hDrvPen = OpenDriver( "pen", NULL, NULL );

if( hDrvPen == NULL )

{

// The pen driver does not exist.

// Either display an error message and exit,

// or continue to function as a pen-unaware application.

}

As an example of how to send the driver messages, the following code uses the pen driver message DRV_SetPenSamplingRate to set the sampling rate to 200 points per second. A later segment of code then queries the driver to get relevant pen infor-mation.

WORD wOldRate;

wOldRate = SendDriverMessage( hDrvPen, // Driver handle

DRV_SetPenSamplingRate, // Message

200, // New rate in Hz

NULL ); // Not applicable

.

.

.

// Get information about the pen driver

PENINFO pi;

BOOL PenHardwareExists;

fPenHardwareExists = SendDriverMessage( hDrvPen,

DRV_GetPenInfo,

(DWORD)(LPPENINFO)&pi,

NULL );

When finished, an application must close the handle to the installable driver with the CloseDriver function, as shown here:

CloseDriver( hDrvPen, NULL, NULL );

Related Links

Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference (win32.hlp)
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008 Free Tect Secrets ;) greatis just4fun network just4fun