Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
How to display Windows On-Screen Keyboard
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to print a bitmap file
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Winsock: sending email messages (SMTP, port 25)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
System Image List Viewer
Custom HttpRequest class (WinHTTP)
Printing Image File, programmatically set print page orientation to landscape
Creating the Save dialog box to specify the drive, directory, and name of a file to save
How to convert a bitmap file to monochrome format (1 bpp)
The window and its ancestors
Mapping and disconnecting network drives
How to download a file from the FTP server using FtpGetFile
Using EnumPrinters function to enumerate locally installed printers
Custom FTP Class for Visual FoxPro application
Displaying icons in the system tray (VFP9)
Displaying the associated icons and descriptions for files and folders
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
How to activate Windows Calculator
Drawing Windows predefined bitmaps using the LoadBitmap functions
Sending email messages with Simple MAPI
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: 88  
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 (50.16.132.180)
43.88 min.Function: 'DrawText'
Function group: 'Font and Text'
43.93 min.Function: 'AVIStreamGetFrame'
Function group: 'Windows Multimedia'
43.98 min.Example: 'Using the NetMessageBufferSend to send messages on the network'
2.23 hrs.Example: 'DiskFreeSpace class'
2.32 hrs.Function: 'GdipGetPageScale'
4.92 hrs.Example: 'Loading a string resource from an executable file'
 Example: 'Retrieving the name of the network resource associated with a local device'
 Function: 'SetBkMode'
5.68 hrs.Example: 'How to display advanced Task Dialog (Vista)'
7.28 hrs.Function: 'AssignProcessToJobObject'
Function group: 'Process and Thread'
Google
Advertise here!