0

I am tired of looking up for method signatures. I'd rather just type something like User32.SendMessage.... Is there something like that?

Basically have a static class with bunch of definitions like :

[DllImport("user32.dll")]
public static extern bool SetParent(int hWndChild, int hWndNewParent);
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Schultz9999
  • 8,717
  • 8
  • 48
  • 87
  • What's wrong with the question? – Schultz9999 Jan 14 '15 at 06:57
  • 1
    I voted to close with reason *Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.* Refer http://stackoverflow.com/help/on-topic – Sriram Sakthivel Jan 14 '15 at 06:58

2 Answers2

3

There is no built in class or static library to do that. However, you could try a google search for some free libraries, or even write your own implementation.

The thing is, user32.dll is part of the win32 api, which was originally meant for C++ applications. When Microsoft rolled out .NET (and soon after, C#), they did not provide native support - in order to run a .NET application, you require the .NET dll binaries.

So until Microsoft decides to rectify this, you'll have to stick with a bunch of definitions.

Forrest4096
  • 159
  • 1
  • 8
  • If a lot of people are using `DllImport` then I thought there should be someone who imported that all. I surely can create a class like that but before spending time, I was wondering if someone else has already done that for me :) – Schultz9999 Jan 14 '15 at 07:22
  • Unfortunately, its like using apples to make orange juice - unless you get messy, it just doesnt work :) – Forrest4096 Jan 14 '15 at 07:28
3

Don't do this.

user32.dll does not contain the same functions across different versions of Windows. If you just blanket-import everything you will most likely ensure that your program can only run on the specific version of Windows that you are currently using.

Every time you import a native function you should check to see what version it came from - and decide whether that is a dependency you can live with.

Jakob Olsen
  • 793
  • 8
  • 13