Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

SetWindowLongPtr on 32-bit #387

Merged
merged 4 commits into from
May 11, 2018
Merged

SetWindowLongPtr on 32-bit #387

merged 4 commits into from
May 11, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 11, 2018

According to the documentation for SetWindowLongPtr,

When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function.

What this really means is that calls to PInvoke.User32.SetWindowLongPtr on 32-bit processes will (and do) result in an EntryPointNotFoundException

This fix exposes SetWindowLongPtr through User32.Helpers.cs by conditionally calling SetWindowLongPtr on 64-bit vs. SetWindowLong on 32-bit.

Also, adding a test.

Fixes #385

According to the documentation for `SetWindowLongPtr`,

    > When compiling for 32-bit Windows, `SetWindowLongPtr` is defined as a call to the `SetWindowLong` function.

What this really means is that calls to `PInvoke.User32.SetWindowLongPtr` on 32-bit processes will (and do) result in an `EntryPointNotFoundException`

This fix exposes `SetWindowLongPtr` through `User32.Helpers.cs` by conditionally calling `SetWindowLongPtr` on 64-bit vs. `SetWindowLong` on 32-bit.
Upating xml-doc comments
Add a test case
@ghost ghost mentioned this pull request May 11, 2018
Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for taking the time to test this. Just one small change please.

/// When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function. This
/// function is exposed using a helper that conditionally calls SetWindowLong in 32-bit processes.
/// </remarks>
[DllImport(nameof(User32), SetLastError = true, EntryPoint = nameof(SetWindowLongPtr))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use nameof(SetWindowLongPtr) for the EntryPoint here. That's the name of the helper method, and if we ever renamed that method, it would not be correct to change the string here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also, I added another definition as part of the latest commit (AdjustWindowRectEx). Just filling in the gaps as I find 'em.

/// through the number of bytes of extra window memory, minus the size of a LONG_PTR. To set any other value,
/// specify one of the following values.
///
/// <list type="table">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice translation to xml! 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, didn't know until now that "list" could mean "table" :)

…of(SetWindowLongPtr) to "SetWindowLongPtr"

- Adding definition for AdjustWindowRectEx
@AArnott AArnott merged commit bc4c683 into dotnet:master May 11, 2018
@AArnott AArnott changed the title Issue #385: SetWindowLongPtr on 32-bit SetWindowLongPtr on 32-bit May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SetWindowLongPtr on 32-bit
2 participants