help! need "translation" from C++

S

Sa¹o Zagoranski

Hi,

I'm trying to play an AVI file from memory with MCI. The documentation is
great
if you want to play a file from a file but directly from memory... almost
nothing.

After hours of searching I found this:
http://support.microsoft.com/kb/q155360/
and after that:
http://binaryworld.net/Main/CodeDetail.aspx?CodeId=3780

Which describes how to do what I want... the problem is that the first code
is in C++ and the second in VB.

For the past few hours I've been trying to translate this into C# but
without any luck. This is what I have so far:

public const long MMIO_INSTALLPROC = 0x10000;
public const long MMIO_GLOBALPROC = 0x10000000;
public const long MEY = 0x2059454D;

[DllImport("winmm.dll")]
private static extern long mmioInstallIOProc(long fccIOProc,
MulticastDelegate pIOProc, long dwFlags);

long retVal = mmioInstallIOProc(MEY, new CallbackDelegate(IOProc),
MMIO_INSTALLPROC | MMIO_GLOBALPROC);

private long IOProc(ref MMIOINFO lpMMIOInfo, long uMessage, IntPtr lParam1,
IntPtr lParam2)
{
.....
}

// NOTE1: I found the definition of MMIOINFO on the second link


Everytime I try calling mmioInstallIOProc I get this warning:
"A call to PInvoke function 'Media!MMedia.Media::mmioInstallIOProc' has
unbalanced the stack. This is likely because the managed PInvoke signature
does not match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature."

I continue execution and see that the movie isn't loaded...

Could someone PLEASE help me with correct "translations" of these methods?

Thank you,
sa¹o
 
M

Michael C

Sa¹o Zagoranski said:
Could someone PLEASE help me with correct "translations" of these methods?

Use int (or Int32) instead of long. Long is 64 bits but the functions are
most likely expecting 32 bits.

You should be using direct show for this now as MCI is very old now.

Michael
 
S

Sa¹o Zagoranski

Changing from long to int didn't help... I still get the same result...

As for the the second suggestion. Doesn't this mean that the user has to
have directx installed on his machine? I don't like this idea very much
since
this means that before the user could use my little player (100kb) he would
have to install 50MB of stuff (.net framework + directx)...
 
M

Michael C

Sa¹o Zagoranski said:
Changing from long to int didn't help... I still get the same result...

Some other parameter must be incorrect in length then or you have too many
params. Did you change the definition of the import or just the consts? Do
you need to use a multicast delegate? I'm not sure what effect this will
have but it might cause a problem.
As for the the second suggestion. Doesn't this mean that the user has to
have directx installed on his machine? I don't like this idea very much
since
this means that before the user could use my little player (100kb) he
would
have to install 50MB of stuff (.net framework + directx)...

That's true.

Michael
 
S

Sa¹o Zagoranski

The first parameters are OK I think the problem might be with the delegate.
you asked about the multicast delegate...
I used it because I saw an example like this on the internet...
What other kind of delegate could I use to pass a callback function to that
method?

sa¹o
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top