Using Win32 functions in Visual FoxPro Image Gallery
File Management
..msdn
CopyFile
CopyFileTransacted
CreateDirectory
CreateFile
CreateFileTransacted
CreateHardLink
CreateSymbolicLink
DeleteFile
DeleteFileTransacted
FindClose
FindCloseChangeNotification
FindFirstChangeNotification
FindFirstFile
FindNextChangeNotification
FindNextFile
FlushFileBuffers
GetBinaryType
GetCurrentDirectory
GetDriveType
GetFileAttributes
GetFileAttributesEx
GetFileInformationByHandle
GetFileType
GetFullPathName
GetLongPathName
GetShortPathName
GetTempFileName
GetTempPath
LockFile
MoveFile
MoveFileTransacted
OpenFile
QueryDosDevice
ReadDirectoryChangesW
ReadFile
RemoveDirectory
RemoveDirectoryTransacted
ReplaceFile
SearchPath
SetCurrentDirectory
SetEndOfFile
SetFileAttributes
SetFilePointer
SetFilePointerEx
SetSearchPathMode
UnlockFile
WriteFile
_lclose
_lopen
Code examples:
Creating a file, then moving it to another destination
How to convert a bitmap file to monochrome format (1 bpp)
How to set Creation Date/Time for a folder (WinNT)
HOWTO: Use the Win32 API to Access File Dates and Times
Monitoring changes occurring within a directory
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Peer-to-peer LAN messenger built with Mailslot API functions
Storing content of the Clipboard to a bitmap file
Storing screen shot of a form to bitmap file
Subclassing CommandButton control to create BackColor property
Testing serial ports
Using InternetSetFilePointer when resuming interrupted download from the Internet
Using mailslots to send messages on the network
Using named pipes for interprocess communication
Using the CreateFile
Using the DeleteFile
Vertical Label control
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: 75  
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.22.127.92)
1.49 hrs.Example: 'How to fill a buffer with random bytes using Cryptography API Functions'
2.08 hrs.Example: 'How to display the Properties dialog box for a file (ShellExecuteEx)'
5.02 hrs.Example: 'GDI+: printing vertical text on VFP reports via generated images (VFP8)'
 Function: 'AlphaBlend'
Function group: 'Bitmap'
 Example: 'Using MessageBeep'
Language: 'C#'
11.08 hrs.Example: 'Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)'
 Example: 'Retrieving long values associated with the class of the VFP window'
11.31 hrs.Function: 'SHSimpleIDListFromPath'
 Function: 'AddPrinter'
Function group: 'Printing and Print Spooler'
11.42 hrs.Example: 'Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)'
Google
Advertise here!