devxlogo

Retrieve the size of an AVI movie

Retrieve the size of an AVI movie

To retrieve the original size of an AVI file that you’ve already opened with the mciSendString API function you can use this command

Dim RetString As StringRetString = Space$(256)CommandString = "where AVIFile destination"RetVal = mciSendString(CommandString, RetString, Len(RetString), 0)

Notice that in this case you’ve to pas a non-null RetString and his length in the second and third parameter respectively. When the function returns, it will contain the four coordinates (X1 Y1 X2 Y2) of the area used by the movie, for instance

    "0 0 320 240" 

indicates that the width is 320 and height 240 pixel. To extract this information you must extract the null terminated string out of the buffer, and then parse the result. If you’re using VB6 you can write a concise code that does it as follows:

' extract the null-terminated stringRetString = Left$(RetString, InStr(RetString & vbNullChar, vbNullChar) - 1)' return the information in a zero-based array of stringsDim res() As Stringres() = Split(RetString)' width is in the 3rd element, height is in the 4th elementwidth = CSng(res(2))height = CSng(res(3))

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist