By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Looking for good referencing on unmanaged code interop

P: n/a
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.

Sep 22 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JDeats

Some links in a not ordered sequence except the first one which I would
really start with when I have a problem with this.

http://www.dotnetinterop.com/

http://www.activevb.de/rubriken/apiv...viewereng.html

http://msdn.microsoft.com/library/de...l/win32map.asp

http://www.pinvoke.net/

I hope this helps,

Cor
"JDeats" <Je**********@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
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.

Sep 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.