Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using the FindMediaType function
Drawing Windows frame controls using the DrawFrameControl function
Storing screen shot of a form to enhanced metafile (*.emf)
A client for testing non-blocking Winsock server
Creating a window using CreateWindowEx function
How to delete all print jobs for a printer
How to play MIDI notes
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Retrieving information about the main VFP window
Accessing Adobe Reader 7.0 main menu from VFP application
Displaying icons in the system tray (VFP9)
Displaying OS Memory Status
Retrieving size of a remote file
Drawing a rectangle using Windows regular edges and borders
Retrieving a universal form for the drive-based path for a network resource
Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)
How to retrieve the number of print jobs queued for the printer
Scanning the hierarchy of child windows down from the main VFP window
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
Extended MessageBox Class
GDI+ fun: roach-infested desktop
Retrieving the command line for the VFP session
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
GDI+: Creating thumbnails to preview images in a directory
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: 82  
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 (72.44.48.122)
4 sec.Function: 'GdipDisposeImage'
3.19 hrs.Function: 'LocalSize'
3.53 hrs.Example: 'Displaying the main Dial-Up Networking dialog box'
 Example: 'How to create a desktop shortcut (shell link)'
 Example: 'Creating a directory on the FTP'
3.65 hrs.Function: 'getservbyname'
 Function: 'NetMessageNameAdd'
Function group: 'Network Management'
7.74 hrs.Example: 'Round FoxPro form'
 Function: 'MAPILogon'
Function group: 'Simple MAPI'
8.66 hrs.Function: 'DeleteEnhMetaFile'
Google
Advertise here!