Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Process APIs provide IntPtr needing explicit cast for HWD methods #560

Closed
michael-hawker opened this issue Jun 28, 2021 · 2 comments
Closed

Comments

@michael-hawker
Copy link

Was told to follow issue here from this conversation.

The C# Process APIs use the IntPtr type, for instance when trying to get the handle from a Process here.

When then making a Win32 call to something like SetForegroundWindow this needs to be explicitly cast to the generated HWD wrapper (which is unintuitive):

PInvoke.SetForegroundWindow((HWD)process.MainWindowHandle);

It'd be great if the generated methods could directly accept the IntPtr type from C# or the generated HWD helper to have an implicit converter setup to do the cast directly for the developer.

Thanks!

@mikebattista
Copy link
Collaborator

mikebattista commented Jun 29, 2021

@AArnott I think this would be a request of the projection. The Process API referenced here is the .NET API not a Win32 API. The request is to accept IntPtr wherever HWND is accepted to avoid the (HWND) cast.

@AArnott
Copy link
Member

AArnott commented Jun 29, 2021

Ah, I may have misunderstood the feedback. I thought the IntPtr was coming from the metadata, but I see now it's coming from a BCL type.
@michael-hawker, I'm sorry to misdirect you. I'll reply again on that discussion. Let's close this issue since there's nothing for the metadata repo to do.

@AArnott AArnott closed this as completed Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants