Intermec 6100 Reference Guide

Page of 328
APPENDIX B
Common PEN*KEY 6000 Series Information
B-6    PEN*KEY
R
 6100 Computer Programmer’s Reference Guide
tagPOWER_STATUS PwrStat;
// Holds current power status.
WORD Error;
// Holds error codes.
char MsgBuf[100];
// Message buffer
#pragma argsused
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  LPSTR lpCmdLine, int nCmdShow) {
  // Turn off the “File not found” error box.
  SetErrorMode(SEM_NOOPENFILEERRORBOX);
  // Get handle to NORAPM.DLL driver
  hinstNorAPM = LoadLibrary(”NORAPM.DLL”);
  // Did we find the library?
  if (hinstNorAPM > HINSTANCE_ERROR) {
    // Get Entry point for GetPowerStatus()
    fpGetPowerStatus lpfnGetPowerStatus = (fpGetPowerStatus)
      GetProcAddress(hinstNorAPM, ”GetPowerStatus”);
    if (lpfnGetPowerStatus) {
      // Get and display charge state
     do {
Error = lpfnGetPowerStatus(&PwrStat);
if (Error != PWR_OK) {
  wsprintf(MsgBuf,
    “GetPowerStatus() call failed with result of %d”, Error);
  Error = MessageBox(NULL, MsgBuf, szTitle,
    MB_RETRYCANCEL + MB_ICONEXCLAMATION);
} // then
else {
  // Display battery status
  wsprintf(MsgBuf, “A/C is %s line.\nBattery is %scharging\n”,
 (char far *) 
 (PwrStat.LineStatus == 1 ? “on” : “off”),
 (char far *) 
 (PwrStat.BatteryFlags & 8 ? “” : “NOT ”));
  Error = MessageBox(NULL, MsgBuf, szTitle,
MB_RETRYCANCEL + MB_ICONINFORMATION);
} // else
 } while (Error == IDRETRY);
  } // then
  else
 MessageBox
(NULL, “Could not get entry point for GetPowerState()!”,
szTitle, MB_OK | MB_ICONEXCLAMATION);
  // Free NorAPM instance.  It stays around since it was already open.
  FreeLibrary(hinstNorAPM);
} // then
else
  MessageBox(NULL, “Could not open NORAPM.DLL!”, szTitle,
MB_OK | MB_ICONEXCLAMATION);
// Exit application
return (0);
} // WinMain
Critical Error Handler: CRITICAL.C
CRITICAL.C is a C++ program that demonstrates a method for handling critical
errors.  This sample program was designed for a previous PEN*KEY 6000 Series
product and may need altering for the 6100 Computer.
#include “stdio.h”
#include “compat.h”
#include “4800.h”
extern
uchar jamarray[4][1024];
B. Common PEN*KEY
6000 Series Info.