Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving the interface–to–IP address mapping table
CryptoAPI: Collection of Providers class
How to copy the image of a form to the Clipboard using Bitmap API functions
How to retrieve adapter information for the local computer (including MAC address)
Moving shortcut to a specified position on the Windows Desktop
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Reading parameters of streams in AVI file
Semi-transparent Form
How to assemble an array of strings and pass it to external function
How to retrieve list of system DSNs (Data Source Name) with parameters
Opening the Page Setup dialog box to specify the attributes of a printed page
Retrieving local computer and user names
How to enumerate sessions and processes on a specified terminal server
Smart Card Database Query Functions
Using FtpCommand
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
Quering a waveform-audio input device
GDI+: Drawing a Pie Chart
How to read email messages using Simple MAPI
How to view icons stored in executable files (Icon Viewer)
Reading header information from AVI file
Starting external program from VFP and waiting for its termination
Disconnecting USB Mass Storage Device programmatically
Displaying dimmed window behind VFP top-level form
Using the CreateFile

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
 
#DEFINE CREATE_NEW 1
#DEFINE CREATE_ALWAYS 2
#DEFINE OPEN_EXISTING 3
 
#DEFINE FILE_ATTRIBUTE_NORMAL 128
 
#DEFINE GENERIC_READ   0x80000000
#DEFINE GENERIC_WRITE  0x40000000
#DEFINE GENERIC_ALL    0x10000000
#DEFINE MAXIMUM_ALLOWED 0x02000000
#DEFINE STANDARD_RIGHTS_ALL 0x001F0000
 
#DEFINE FILE_SHARE_READ 1
#DEFINE FILE_SHARE_WRITE 2
#DEFINE FILE_SHARE_DELETE 4
#DEFINE INVALID_HANDLE_VALUE -1 
 
DO declare
 
hFile = CreateFile("c:\temp\myfile.txt",;
            GENERIC_WRITE,;
            FILE_SHARE_WRITE,;
            0,;
            CREATE_ALWAYS,;
            FILE_ATTRIBUTE_NORMAL,;
            0)
 
IF hFile <> INVALID_HANDLE_VALUE
    ? "File handle returned: ", hFile 
    = CloseHandle (hFile)
ELSE
    *  2 = ERROR_FILE_NOT_FOUND
    *  3 = ERROR_PATH_NOT_FOUND
    * 13 = ERROR_INVALID_DATA
    * 87 = ERROR_INVALID_PARAMETER
    ? "Error code returned:", GetLastError()
ENDIF
* end of main
 
PROCEDURE declare
    DECLARE INTEGER GetLastError IN kernel32
    DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
 
    DECLARE INTEGER CreateFile IN kernel32;
        STRING lpFileName, INTEGER dwDesiredAccess,;
        INTEGER dwShareMode, INTEGER lpSecurityAttr,;
        INTEGER dwCreationDisp, INTEGER dwFlagsAndAttrs,;
        INTEGER hTemplateFile
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1209 bytes  
Created: 2001-07-12 12:00:00  
Modified: 2005-12-12 11:25:12  
Visits in 7 days: 98  
Listed functions:
CloseHandle
CreateFile
GetLastError
Printer friendly API declarations
My comment:
This example creates a new file and closes it.
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:
213.91.206.122 | 2005-08-05 08:08:52
It is working pretty good but I don't know how to open COM port / I mean what must be the "lpFileName" to open for example COM2

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 (107.20.129.212)
3 sec.Example: 'How to make a VFP form fading out when released (GDI+ version)'
2.75 hrs.Example: 'Custom HttpRequest class (WinHTTP)'
 Example: 'Using Change Notification Objects to monitor changes to the printer or print server'
3.05 hrs.Example: 'How to delete all print jobs for a printer'
 Example: 'How to change the name and the size of the font in the MessageBox dialog'
4.97 hrs.Example: 'Attaching menu to a top-level form'
 Function: 'SetWindowRgn'
Function group: 'Painting and Drawing'
10.02 hrs.Example: 'Using named pipes for interprocess communication'
 Function: 'keybd_event'
16.37 hrs.Example: 'Pocket PC: creating new database in the Object Store and copying Contacts Database records into it'
Google
Advertise here!