views:

970

answers:

2

I am a newbie to API calls in .NET.

I am looking at the documentation for a method I want to call here

EDIT The method is a Windows Mobile API call.

To call it, I need to know what dll it is in and what the values are for any parameter flags (and other stuff but this is just an example).

So where do I find this out? It's not on the page. It tells me the header file and the names of the flag values but that doesn't help me. Searching MSDN brings back references to Windows API methods instead of Windows Mobile API methods.

Sure, I can guess that it's in coredll.dll. I can google to find code someone else has written and see how they've done it. I have in fact done that and it is indeed in coredll.dll.

I can't guess the flag values. So I'm stuck there unless I can find someone elses code which may or may not be right.

So my question is: Surely the containing dll and the flag values are key info? So I should be able to find this info somewhere in MSDN?

If I was looking at a page about an FCL class, it would tell me what dll the class is defined in, the namespace and a whole lot of other info and links I need to be able to use it.

The info must be there as I don't see any other questions like this around the net?

+6  A: 

You should check out PInvoke, it'll detail most WinAPI calls.

The specific flags you're looking for can be found here.

Kieron
J M
What do you need that is not there?
Martinho Fernandes
The values of SW_HIDE, SW_SHOW, etcThe signature of the call in coredll.dll - PInvove lists it for user32.dll
J M
Doesn't matter, the values will be the same for Win32 and WinCE.
Kieron
Ah - sorry, being thick, didn't notice it was a link. I'm going to take it that PInvoke is the API bible and that the signatures are the same for mobile and leave this question at that.
J M
@J M: You're right about PInvoke.
Martinho Fernandes
Thanks for the responses - this site is like greased lightening.
J M
Be forewarned that not all APIs are identical from desktop to device and that P/Invoke.net is not always right. What that means is you certainly should learn how to write calls from the header documentation.
ctacke
The signatures aren't always correct and there's no replacement for the header files or MSDN. But in case of enums, they're mainly always the same - although, the CE ones aren't usually as expansive.
Kieron
I am interested to learn more about writing calls using the header documentation. I went straight into .NET i.e. did not move on from C++ unfortunately so there are fairly large gaps in my knowledge that I am trying to plug. I'll google it ofc but if you know of any useful links I'd appreciate it.
J M
I'd suggest you start by downloading the Windows SDK from Microsoft. All the headers are in there, you can use it in conjunction with the help files that come with it. You'll find it's fairly simple to convert them to .Net calls or just use pInvoke. But it's good to understand how these things work.
Kieron
A: 

Well officially this is "caling of unmanaged dll" or PInvoke (Platform Invoke) using by Marshaling ,
the most full library PInvoke is http://www.pinvoke.net/ as mentioned before.
I recommend the Winspector tool for understanding the low level messages that use in windows.

Avram