Search code examples
c#audiocompact-frameworkwindows-cedllimport

DllImport difference between Compact Framework and Full Framework


I have an application written in .NET Compact Framework 3.5 for use on Windows CE.

The application also runs perfectly well on any full framework windows OS.

I want to add volume control to my application and the required DllImport is as below for a full framework OS:

[DllImport("winmm.dll")]  
public static extern long waveOutSetVolume(UInt32 device, UInt32 Volume);  

For the compact framework it is:

[DllImport("coredll.dll", SetLastError=true)]
public static extern long waveOutSetVolume(UInt32 device, UInt32 Volume);  

The only real difference between the two is the name of the DLL that DllImport requires.

Windows CE requires the coredll.dll while full windows requires winmm.dll?

What to do here besides create different releases of the .exe?


Solution

  • You can offer two static classes for loading the dll, one for coredll.dll and one for winmm.dll. Depending on your platform ( which you can provide in your application ) you just need to use the right class.

    The dll-loading will be done when you try to access the exported function the first time so this approach shall work.