microsoft / microsoft/CsWin32

GetIconInfo requires either pointers or declaring a new SafeHandle class to wrap a HICON you don't own

Open
#256 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
2.5k
Forks
124
Avg merge
1d 3h
Merged PRs (30d)
9

Description

I'm currently defining my own UnownedHandle type to work around this, but I'd really like to delete it.

ICONINFO M(HICON iconHandle)
{
    if (!PInvoke.GetIconInfo(new UnownedHandle(iconHandle), out var iconInfo)) throw new Win32Exception();
    return iconInfo;
}

I obtained the HICON from a struct field from an API that only returns handles that I don't own.

Referencing only CsWin32 0.1.445-beta

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests; start at the generated PInvoke.GetIconInfo declaration and the UnownedHandle workaround. Done means allowing a borrowed HICON from a struct field to be passed without declaring a custom SafeHandle, while preserving its non-ownership; inspect existing handle parameter conventions before deciding the API shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.