views:

39

answers:

1

I'd like to call SndGetSoundFileList from c#, but I got no idea how the p/invoke for this function needs to be, due to the pointer parameters.

HRESULT SndGetSoundFileList (
   SND_EVENT seSoundEvent,
   DWORD grfLocations, 
   SNDFILEINFO** ppSoundFiles,
   int* pcSoundFiles
);

I'd like to get the list as a string-array, of course.

Can anyone help me here?

Thanks!

+2  A: 

For the array parameter, use out IntPtr as the parameter type. Then use Marshal.PtrToStructure to retrieve the structures, and call LocalFree to free the memory when you're done.

Mattias S
Using out IntPtr is easy, but I can't get Marshal.PtrToStructure to convert the ppSoundFiles to an array of the structure. Is there a trick there?
Sam
You have to manually marshal it.
ctacke