Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Winsock: sending email messages (SMTP, port 25)
Custom GDI+ class
Using EnumPrinters function to enumerate locally installed printers
Semi-transparent Form
Custom HttpRequest class (WinHTTP)
Custom HttpRequest class (WinINet)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
How to convert a bitmap file to monochrome format (1 bpp)
Compressing and decompressing files with Windows API Runtime Library routines
Printing Image File, programmatically set print page orientation to landscape
Custom FTP Class for Visual FoxPro application
How to create MD-5 and SHA-1 hash values from a string
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Extended MessageBox Class
Transparent Menu Class (requires VFP9)
Adding icon to the systray (requires VFP9)
Creating irregularly shaped FoxPro form using transparency color key
How to ping a remote site using ICMP API calls
How to create non-blocking Winsock server
Using Month Calendar Control (VFP9, Comctl32.dll)
How to print FoxPro form
How to detect if additional monitor is connected and active
GDI+: Creating thumbnails to preview images in a directory
Get the power status of your laptop computer

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
This code sample helps to find whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains.
 
DECLARE INTEGER GetSystemPowerStatus IN kernel32;
    STRING @lpSystemPowerStatus
 
*|typedef struct _SYSTEM_POWER_STATUS {
*|  BYTE ACLineStatus;         0:1
*|  BYTE BatteryFlag;          1:1
*|  BYTE BatteryLifePercent;   2:1
*|  BYTE Reserved1;            3:1
*|  DWORD BatteryLifeTime;     4:4
*|  DWORD BatteryFullLifeTime; 8:4
*|} SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS; total 12 bytes
 
LOCAL cBuffer
cBuffer = Repli(Chr(0), 12)
IF GetSystemPowerStatus(@cBuffer) = 0
    RETURN
ENDIF
 
LOCAL nStatus, nBattery
nStatus = Asc(SUBSTR(cBuffer,1,1))
nBattery = Asc(SUBSTR(cBuffer,2,1))
 
? "AC power status: "
DO CASE
CASE nStatus = 0
    ?? "offline"
CASE nStatus = 1
    ?? "online"
OTHER
    ?? "unknown"
ENDCASE
 
? "Battery flag: "
DO CASE
CASE nBattery = 1
    ?? "high"
CASE nBattery = 2
    ?? "low"
CASE nBattery = 4
    ?? "critical"
CASE nBattery = 8
    ?? "charging"
CASE nBattery = 128
    ?? "no system battery"
OTHER
    ?? "unknown"
ENDCASE
 
IF nBattery <= 8
    ? "Battery remaining, %:", Asc(SUBSTR(cBuffer,3,1))
    ? "Battery remaining, sec:", buf2dword(SUBSTR(cBuffer,5,4))
    ? "Battery full time, sec:", buf2dword(SUBSTR(cBuffer,9,4))
ENDIF
* end of main
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1406 bytes  
Created: 2001-07-12 12:00:00  
Modified: 2006-01-05 13:11:07  
Visits in 7 days: 17  
Listed functions:
GetSystemPowerStatus
Printer friendly API declarations
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2010 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.0.85), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (38.107.191.109)
7.2 min.
Function group: 'Shell Lightweight Utility APIs -- misc. functions'
11.9 min.
Function group: 'Remote Access Service (RAS)'
5 day(s)Example: 'Winsock: sending email messages (SMTP, port 25)'
Google
Advertise here!