Skip to content

Minor Code Improvements | Error handling in IconExtractor.cs #1

@bbbjames

Description

@bbbjames

The file has extensive P/Invoke code that's currently working well, but could benefit from error handling consolidation:

// Consider adding a wrapper method to reduce repetition
private static Icon? TryGetIconFromImageList(string filePath, int imageListType)
{
    try
    {
        SHFILEINFO shinfo = new SHFILEINFO();
        IntPtr result = SHGetFileInfo(filePath, 0, ref shinfo, 
            (uint)Marshal.SizeOf(shinfo), SHGFI_SYSICONINDEX);
        // ... rest of logic
    }
    catch
    {
        return null;
    }
}

Metadata

Metadata

Assignees

Labels

featureNew feature or request enhancementgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions