Tuesday, Jul 15, 2003, 8:26 AM
Interop Declarations for Windows.h
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:
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




