473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

AVIFileInfo throws NullPointerException

Hello!

Im sitting here and trying to retreive som avi information, but the
invoke of the AVIFileInfo throws a nullpointer exception.

snipp
-------
public struct AVIFILEINFO {
public long dwMaxBytesPerSec;
public long dwFlags;
public long dwCaps;
public long dwStreams;
public long dwSuggestedBufferSize;
public long dwWidth;
public long dwHeight;
public long dwScale;
public long dwRate;
public long dwLength;
public long dwEditCount;
public string szFileType;
}

class Class1 {
....
[DllImport("avifil32.dll")]
private static extern void AVIFileInit();

[DllImport("avifil32.dll")]
private static extern void AVIFileExit();

[DllImport("avifil32.dll")]
private static extern long AVIFileOpen(ref long ppfile, string
szFile, long mode, object pclsidHandler);

[DllImport("avifil32.dll")]
private static extern long AVIFileRelease(long pfile);

[DllImport("avifil32.dll")]
private static extern long AVIFileInfo (long pfile, ref AVIFILEINFO
pfi, long lSize);
....

public Class1() {
AVIFileInit();
long hFile = 0;
AVIFILEINFO aviInfo = new AVIFILEINFO();
AVIFileOpen(ref hFile, @"C:\klowner.avi", 0, null);
AVIFileInfo(hFile, ref aviInfo,
System.Runtime.InteropServices.Marshal.SizeOf(aviI nfo));
AVIFileRelease(hFile);

AVIFileExit();
}
}

AVIFileOpen returns long, 68116944363978752
When the exception is thrown hFile == 3761212

Anyone have any clue?

Regards,
Lars
Nov 15 '05 #1
1 4163
Lars,
public struct AVIFILEINFO {
public long dwMaxBytesPerSec;
public long dwFlags;
public long dwCaps;
public long dwStreams;
public long dwSuggestedBufferSize;
public long dwWidth;
public long dwHeight;
public long dwScale;
public long dwRate;
public long dwLength;
public long dwEditCount;
public string szFileType;
}
All longs should be changed to (u)ints. The szFileType member should
have the attribute

[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]

and the struct itself should have

[StructLayout(LayoutKing.Sequential, CharSet=CharSet.Auto)]

[DllImport("avifil32.dll")]
private static extern long AVIFileOpen(ref long ppfile, string
szFile, long mode, object pclsidHandler);

[DllImport("avifil32.dll")]
private static extern long AVIFileRelease(long pfile);

[DllImport("avifil32.dll")]
private static extern long AVIFileInfo (long pfile, ref AVIFILEINFO
pfi, long lSize);


This should be

[DllImport("avifil32.dll", CharSet=CharSet.Auto)]
private static extern uint AVIFileOpen(out IntPtr ppfile, string
szFile, uint mode, IntPtr pclsidHandler);

[DllImport("avifil32.dll")]
private static extern uint AVIFileRelease(IntPtr pfile);

[DllImport("avifil32.dll", CharSet=CharSet.Auto)]
private static extern uint AVIFileInfo(IntPtr pfile, out AVIFILEINFO
pfi, int lSize);


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
oll3i
by: oll3i | last post by:
nevermind the previous prob i posted i m getting further and i get a new exception in readFile method pleae help me with that one thank u a lot in advance java.lang.NullPointerException...
3
oll3i
by: oll3i | last post by:
double dystanse = null; Integer czyNajblizszySasiad = null; Integer najblizszySasiad=null; System.out.println("Przed 1 petla for"); ...
1
by: ketand1 | last post by:
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; class DbAwt extends Frame implements ActionListener { private...
1
by: Charles | last post by:
I was able to do this but for no reason I can think of, now I cannot login to my Oracle Management Server. When Oracle Enterprise Manager starts up and I choose to login to OMS, it throws up a java...
2
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
1
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
15
oll3i
by: oll3i | last post by:
Thank you for the last post :) now another problem when i flush the session hibernate throws nullpointerexception my code looks as follows import org.hibernate.Session; import...
1
by: r035198x | last post by:
This exception occurs often enough in practice to warrant its own article. It is a very silly exception to get because it's one of the easiest exceptions to avoid in programming. Yet we've all got it...
3
by: chris123456789 | last post by:
Hi, when I run my code I get a NullPointerException:null. Here is the part of the code where the error occurs: import java.util.*; import java.io.*; public class Decrypt { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.