Looking for good referencing on unmanaged code interop

J

JDeats

I'm doing Windows Mobile 5 programming and since MS has not exposed
most of the functionality i have to call DllImport a lot, I haven't
done much interop with unmanaged code, I'm looking for the best
tutorial (pubished work or web site link) on how to make sense of how
to do this... A simple example is the PlaySound WINAPI method, which
looks like this

BOOL WINAPI PlaySound(
LPCSTR pszSound,
HMODULE hmod,
DWORD fdwSound
);


I found a sample of how to make a reference ot this

[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError =
true)]
private extern static int WCE_PlaySound(string szSound, IntPtr
hMod, int flags);

I need a reference ot match managed attribute type to unmanaged type
(e.g. DWORD=int, HMODULE=IntPtr, etc....)

Also, what all is possible with DllImport? Can I import .LIB's as well
as .DLL's. How would I make use of a structure? Could i use DllImport
to create a usable instance of this in C#?

typedef struct tag_CM_VOICE_RECORDER {
WORD cb;
DWORD dwStyle;
Int xPos, yPos;
HWND hwndParent;
Int id;
LPTSTR lpszRecordFileName;
} CM_VOIC

Sorry for all the questions.
 

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

Similar Threads


Top