Skip to content

Files

Latest commit

 

History

History
165 lines (148 loc) · 11.4 KB

GetLastError.md

File metadata and controls

165 lines (148 loc) · 11.4 KB

Home

Function name : GetLastError

Group: Error Handling - Library: kernel32


The GetLastError function retrieves the calling thread"s last-error code value.


Code examples:

Creating a folder
Start an executable from VFP application by using the CreateProcess
Using LoadLibrary
Using the Semaphore object
Using the CreateFile
How to access a file using not its name but an alias (hard link)
Closing Windows
Retrieving local computer and user names
Scanning a hierarchy of child windows down from the Windows Desktop
How to fill a buffer with random bytes using Cryptography API Functions
Converting long file names to the short format and vice versa
Setting the last-error code for the FoxPro
Using FtpCommand
Setting the date and time that a file was created
How to remove FTP directory
Retrieving the System Time adjustment
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Enumerating printer drivers installed
Retrieving a handle to DLL and address of an exported function in it
How to test file attributes (key method for FileExists and DirectoryExists routines)
Basic Volume information
DiskFreeSpace class
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Wininet last error description
How to download this reference's archive through WinInet functions using InternetOpenUrl
Setting the Window Region for a form
How to initiate System shutdown
Finding parameters for the region specified
Enumerating the subkeys of a user-specific key
Reading current hardware profile
How to save registry key including its subkeys and values to a file
How to find the application associated with a file name
Creating a device context for the specified printer
Using EnumPrinters function to enumerate locally installed printers
Using the Semaphore object to allow only one instance of VFP application running
Setting the volume label
Locking and unlocking file of a VFP table
Retrieving graphic capabilities of default printer
Enumerating Processes -- WinNT
HOWTO: Use the Win32 API to Access File Dates and Times
Custom HttpRequest class (WinINet)
Validating the heap of the calling process
How to write and read Window Properties for the specified window
Converting command-line string to a set of Unicode argument strings
Winsock: retrieving information from a host database for a given host name
Creating a mailslot
Getting a bit more than the _CLIPTEXT offers
Displaying bitmap using the AlphaBlend function
Locking the workstation
Testing serial ports
Converting Unicode data from the Clipboard to a character string using a given code page
How to display the Properties dialog box for a file (ShellExecuteEx)
Determining if an Active Network Connection is Available
How to retrieve information about a cache entry (Internet Explorer)
Enumerating print processors and supporting data types installed on the specified server
Enumerating ports that are available for printing on a specified server
Adding printer to the list of supported printers for the specified server
Reading the structure of VFP main menu
The DetectAutoProxyUrl function identifies the auto-config script location
Custom FTP Class for Visual FoxPro application
How to enumerate cookies and URL History entries in the cache of the local computer
Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)
How to display the port-configuration dialog box for a port on the specified server
How to retrieve the number of print jobs queued for the printer
Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)
How to retrieve configuration data for a specified printer stored in the registry (PrinterDriverData key)
How to delete all print jobs for a printer
Retrieveing information about the active window (even if it is not owned by the calling process)
Simple printer queue monitor: deletes, pauses, resumes print jobs for local printer
Starting external program from VFP and waiting for its termination
How to ping a remote site using IP Helper API calls
Enumerating forms supported by a specified printer
Custom HttpRequest class (WinHTTP)
How to set Creation Date/Time for a folder (WinNT)
Monitoring changes occurring within a directory
Storing registration key in the resources of an executable file
Peer-to-peer LAN messenger built with Mailslot API functions
How to Start a Process as Another User (NT/XP/2K)
How to play AVI file on the _screen
How to block the ALT+TAB shortcut (WinXP)
GetFileOwner - Get the owner of an NTFS file
CryptoAPI: Collection of Providers class
How to run FoxPro application under different user name (impersonating user)
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
Using File Mapping for enumerating files opened by Visual FoxPro
Creating a console window for Visual FoxPro application
Encapsulating access to the Windows Services in a class
How to retrieve version information for the specified file
How to create MD-5 and SHA-1 hash values from a string
How to extract frames from AVI files
Using Change Notification Objects to monitor changes to the printer or print server
How to block the PrintScreen key
How to make application automatically close all documents it opened
How to prevent users from accessing the Windows Desktop and from switching to other applications
Using the NetMessageBufferSend to send messages on the network
Using shared memory to exchange data between applications (processes)
How to display a user-defined icon in the MessageBox dialog
A class that encrypts and decrypts files using Cryptography API Functions
Reading security permissions for NTFS files and folders
How to create a service object
How to delete a service object
How to enumerate sessions and processes on a specified terminal server
How to enumerate terminal servers within the specified Windows domain
Using named pipes for interprocess communication
Reading entries from Event logs
How to find when the application started
Obtaining I/O counts for the current process
Copying files as a transacted operation (Vista)
How to adjust monitor brightness (Vista, monitor with DDC support)
How to enable the SE_SHUTDOWN_NAME privilege for the application
Reading and setting system access privileges for the current process
Printing Image File, programmatically set print page orientation to landscape
How to find which fonts Windows uses for drawing captions, menus and message boxes
Writing entries to custom Event Log
Compressing and decompressing files with Windows API Runtime Library routines
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Displaying dimmed window behind VFP top-level form
Setting default printer
Generating random cryptographic keys
Monitoring clipboard content changes (VFP9)
How to load a user profile

Declaration:

DWORD GetLastError(VOID);  

FoxPro declaration:

DECLARE INTEGER GetLastError IN kernel32  

Parameters:

This function has no parameters


Return value:

The return value is the calling thread"s last-error code value


Comments:

To obtain an error string for system error codes, use the FormatMessage function.

The following MS link provides the list of existing error codes: Win32 Error Codes