Interop Declarations for Windows.h

Here. "This post includes C# definitions of many common Win32APIs and their related data structures. It does not include all Win32 APIs and it is missing all #define constants. It was created by a rather complex semi-automatic process. If I get enough requests I will release the source for the process used to create this file." [staff.develop.com/candera/weblog2]


3 comments on this post

Stephane Rodriguez:



This interop file is UTTERLY useless. Here is why : the highly used GetWindowText() is interoped like this :

public static extern unsafe int GetWindowTextA(HWND__* hWnd, sbyte* lpString, int nMaxCount);

Now tell me who as a C# developer is going to use unsafe pointers just to be able to call that function. In addition, as everyone knows, GetWindowText should be passed a "StringBuilder" because a memory block has to be allocated first. Where do we end with that "sbyte*" crap?

Semi-automatic translation leads you nowhere.

The only way to go is MC++. Native calls. Period.


PS : I have personally invested more than a month trying to do such thing, then it became obvious to my mind that :
- it is impossible to automatically translate the API. Anytime a pointer is being used, nothing tells us whether it's an input or output pointer.
- Adam Nathan has preinteroped a few of the windows dll functions including user32.dll and gdi32.dll if I remember well. I believe those are much more reliable.
- MC++ allows anyone to explicitely call windows C/C++ functions. As a result, there is no point in interoping at all.
- performance is drastically reduced because of the marshaling process back and forth.

Tuesday, Jul 15, 2003, 2:20 PM


KLAMATH:


Check this out:

http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=cef35c95-4549-4665-ae0a-ff8232883561

Tuesday, Jul 15, 2003, 11:41 PM


Stephane Rodriguez:



KLAMATH,

Your wrapper library is good to use. Great job. I like it way better than the automated one. Kind of relief since you are exposing well defined methods, hiding all the low-level details : for instance GetWindowText either returns a string out of a window handle, or simply takes a stringbuilder as argument. Which is exactly how things should be.

Did you know Eric Gunnerson (C# PM) also wrote a Window class wrapper, just to reflect a bunch of API methods? I believe he posted the article on MSDN online a couple of months ago.

Wednesday, Jul 16, 2003, 11:48 AM





comment on this post

HTML tags will be escaped.

Powered By ASP.NET

Hosted by SecureWebs

Microsoft

Mensa

IEEE


Best CD Rates
moving companies
addiction treatment
sunglasses
Kratom
How To Lose Weight Fast
cocktail dresses
Credit Card Balance Transfer
Add URL
Stock Trading
Health Insurance Quotes
Promotional Merchandise
Jet Privé
loans for bad credit