Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using MessageBeep
Winsock: retrieving the host information corresponding to a network address
Adding and deleting User Accounts
Compressing and decompressing files with Windows API Runtime Library routines
Downloading files from the FTP server using InternetReadFile
Enumerating print processors and supporting data types installed on the specified server
How to retrieve version information for the specified file
Retrieveing information about the active window (even if it is not owned by the calling process)
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
Retrieving the command line for the VFP session
String representation for disk or memory capacity
Displaying standard progress dialog box when copying files
How to browse and connect to printers on a network (WinNT)
How to play AVI file on the _screen
Locking mouse and keyboard input for the VFP application
Quering a waveform-audio input device
Starting a dialog box for connecting to network resources (mapping network drive)
How to position the GETPRINTER() dialog
Winsock: initializing the service in the VFP application
Winsock: retrieving information from a host database for a given host name
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Validating URLs using moniker functions
Disconnecting USB Mass Storage Device programmatically
Get the power status of your laptop computer

User rating: 10/10 (1 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: 10/10 (1 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: 94  
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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (23.20.196.179)
5 sec.Function: 'LookupPrivilegeDisplayName'
47.5 min.Function: 'AppendMenu'
Function group: 'Menu'
3.88 hrs.Example: 'GDI+: converting text strings to images and saving in a graphics file'
 Example: 'Placing a button on the VFP form as a new child window'
10.07 hrs.Example: 'Class library providing access to the System Registry'
12.96 hrs.Example: 'Using the DrawText function'
13.54 hrs.Example: 'How to download a file from HTTP server using URL Monikers functions'
 Function: 'GetPwrCapabilities'
Function group: 'Power Management'
13.94 hrs.Example: 'How to check whether the system is 32-bit or 64-bit'
14.07 hrs.Function: 'MAPIReadMail'
Google
Advertise here!