Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Starting external program from VFP and waiting for its termination
Using custom Simple MapiSendMail class
How to create transparent areas inside a form -- punching holes in the form
How to find which fonts Windows uses for drawing captions, menus and message boxes
How to generate GUID values
Retrieving list of files on the FTP directory
Writing entries to custom Event Log
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Listing child windows for the Windows desktop
Reading security permissions for NTFS files and folders
Retrieving current settings for an ODBC connection
Finding out if the current user is the Guest account
Locking mouse and keyboard input for the VFP application
Obtaining names and positions for shortcuts located on the Windows Desktop
Scanning a hierarchy of child windows down from the Windows Desktop
Storing screen shot of a form to enhanced metafile (*.emf)
Displaying standard progress dialog box when copying files
How to make the caption of a VFP application flashing in the Windows task bar
How to print picture stored in enhanced-format metafile (*.emf)
How to run FoxPro application under different user name (impersonating user)
Monitoring changes in a directory
Retrieving country-specific dialing information from the Windows Telephony list of countries
Shortcut Menu Class
The DetectAutoProxyUrl function identifies the auto-config script location
Adding supplementary data to AVI files

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
Before you begin:
The code below shows how to add a string to AVI file. The string may contain, for example, a copyright information, comments etc. AVI or MMIO functions can be used later on to read the string.

The code sample is simplified, intended to be only a blue-print. So use it on those AVI files you have copies of.
 
cFile = "findcomp.avi"
? AddInfo_AVI(cFile, "AUTH", SYS(0))
* end of main
 
PROCEDURE AddInfo_AVI(cAviFile, cChunkId, cValue)
#DEFINE OF_SHARE_DENY_WRITE 0x00000020
#DEFINE OF_READWRITE 0x00000002
 
    DO declare2
    = AVIFileInit()
 
    LOCAL hFile, nResult, nChunkId
    IF AVIFileOpen(@hFile, cFile,;
        BITOR(OF_SHARE_DENY_WRITE, OF_READWRITE), 0) <> 0
        RETURN .F.
    ENDIF
 
    nChunkId = buf2dword(PADR(cChunkId,4,CHR(0)))
    nResult = AVIFileWriteData(hFile, nChunkId,;
        @cValue, LEN(cValue))
 
    = AVIFileRelease(hFile)
    = AVIFileExit()
RETURN (nResult=0)
 
PROCEDURE AddInfo_RIFF(cAviFile, cChunkId, cValue)
#DEFINE MMIO_READWRITE  2
#DEFINE MMIO_ALLOCBUF   0x00010000
#DEFINE MMIO_FINDRIFF   0x0020
#DEFINE MMSYSERR_NOERROR 0
 
    DO declare1
 
    LOCAL hFile, cMMIOInfo, cRiffInfo,;
        cChunkInfo, lResult
 
    cMMIOInfo = Repli(Chr(0), 64)
    hFile = mmioOpen(cAviFile, @cMMIOInfo,;
        MMIO_READWRITE+MMIO_ALLOCBUF)
 
    IF hFile <= 0
        RETURN .F.
    ENDIF
 
    cRiffInfo = Repli(Chr(0), 20)
    = mmioDescend(hFile, @cRiffInfo, Null, MMIO_FINDRIFF)
    = mmioAscend(hFile, @cRiffInfo, 0)
 
    cChunkInfo = PADR(PADR(cChunkId,4,CHR(0)) +;
        num2dword(LEN(m.cValue)), 20)
 
    IF mmioCreateChunk(hFile, @cChunkInfo, 0)=0;
        And mmioWrite(hFile, cValue, Len(cValue))=0
        = mmioAscend(hFile, @cChunkInfo, 0)
        lResult=.T.
    ENDIF
 
    = mmioFlush(hFile, 0)
    = mmioClose(hFile, 0)
RETURN m.lResult
 
PROCEDURE declare1
    DECLARE INTEGER mmioClose IN winmm INTEGER hmmio, INTEGER wFlags
    DECLARE INTEGER mmioFlush IN winmm INTEGER hmmio, INTEGER fuFlush
 
    DECLARE INTEGER mmioOpen IN winmm;
        STRING szFilename, STRING @lpmmioinfo, INTEGER dwOpenFlags
 
    DECLARE INTEGER mmioAscend IN winmm;
        INTEGER hmmio, STRING @lpck, INTEGER wFlags
 
    DECLARE INTEGER mmioDescend IN winmm;
        INTEGER hmmio, STRING @lpck,;
        STRING @lpckParent, INTEGER wFlags
 
    DECLARE LONG mmioWrite IN winmm;
        INTEGER hmmio, STRING pch, LONG cch
 
    DECLARE INTEGER mmioCreateChunk IN winmm;
        INTEGER hmmio, STRING @lpck, INTEGER wFlags
 
PROCEDURE declare2
    DECLARE AVIFileInit IN avifil32
    DECLARE AVIFileExit IN avifil32
    DECLARE INTEGER AVIFileRelease IN avifil32 INTEGER pfile  
 
    DECLARE INTEGER AVIFileOpen IN avifil32;
        INTEGER @ppfile, STRING szFile,;
        INTEGER mode, INTEGER pclsidHandler
 
    DECLARE INTEGER AVIFileWriteData IN avifil32;
        INTEGER pfile, LONG ckid,;
        STRING @lpData, LONG cbData
 
FUNCTION num2dword(lnValue)
#DEFINE m0  256
#DEFINE m1  65536
#DEFINE m2  16777216
    IF lnValue < 0
        lnValue = 0x100000000 + lnValue
    ENDIF
    LOCAL b0, b1, b2, b3
    b3 = Int(lnValue/m2)
    b2 = Int((lnValue - b3*m2)/m1)
    b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
    b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
 
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: 0/10 (0 votes)
Rate this code sample:
  • ~
2964 bytes  
Created: 2005-03-01 17:39:33  
Modified: 2009-02-03 15:26:42  
Visits in 7 days: 96  
Listed functions:
AVIFileExit
AVIFileInit
AVIFileOpen
AVIFileRelease
AVIFileWriteData
mmioAscend
mmioClose
mmioCreateChunk
mmioDescend
mmioFlush
mmioOpen
mmioWrite
Printer friendly API declarations
My comment:
AVI formats support adding supplementary data (other than normal header, format, and stream data) to AVI files.

The Microsoft AVI file format is a RIFF file specification, so any supplementary data can be added in the chunk format. A chunk consists from ID (4 bytes), data size (4 bytes) and the data itself (up to 0xffffffff bytes).

Here is an example of chunk with supplementary data:
CPRT*000Copyright (c) 2001-2005. Such-n-such, Inc.

Where CRPT is 4-byte ID. *000 is the binary presentation (DWORD) of number 42, which is the length of the data. And Copyright (c) 2001-2005. Such-n-such, Inc. is the data.

In less sophisticated way, FoxPro low-level file functions most liekly can be used to open AVI file and attach some data to the end of it.

If you prefer playing by rules, use either AVI or MMIO API functions. Two procedures in the code above present both ways. Well, neither AVIFileWriteData nor mmioCreateChunk works smart enough.

The AddInfo_AVI adds new chunk to the AVI file regardless of whether a chunk with this ID already exists. If you decide to read the supplementary information using the AVIFileReadData, it will read only the first chunk found.

The AddInfo_RIFF always adds a chunk immediately after the main part of the file. Although, you may modify the code, making it search through existing chunks. In my opinion, MMIO functions have much greater flexibility. With them you can build a real routine for adding, reading and modifying supplementary data in AVI files.
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 (54.235.20.17)
4 sec.Function: 'GetWindow'
7 sec.Example: 'Using the ChooseColor function'
1.28 hrs.Example: 'Winsock: resolving an address to a host name'
 Example: 'Storing screen shot of a form to bitmap file'
5.56 hrs.Example: 'Pocket PC: Folder Viewer'
 Example: 'Printing text on the main VFP window'
7.05 hrs.Example: 'Creating a device context for the specified printer'
9.07 hrs.Example: 'How to find the application associated with a file name'
9.08 hrs.Example: 'Programmatically removing submenus from VFP main menu'
 Example: 'Using mailslots to send messages on the network'
Google
Advertise here!