Skip to content

Bug: Win32::Foundation::HINSTANCE is not generated #1517

Closed

Description

Which crate is this about?

windows

Crate version

0.48.0

Summary

The type Win32::Foundation::HINSTANCE is not generated in 0.48.0 of the windows crate. I have faced such an issue in the 0.47.0 version also.

Toolchain version/configuration

Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\momin.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.67.1 (d5a82bbd2 2023-02-07)

Reproducible example

use windows::Win32::Foundation::HINSTANCE;

pub static mut DLL_INSTANCE: HINSTANCE = HINSTANCE(0);

Crate manifest

[dependencies.windows]
version = "0.48"
features = [
    "Win32_Foundation"
]

Expected behavior

The type is generated and accessible.

Actual behavior

Not generated.

Additional comments

No response

Activity

  1. riverar commented on Apr 1, 2023

    @riverar
    Collaborator

    Hi Muhammad Mominul Huque (@mominul), use HMODULE instead. See #1508 for more background.

  2. added
    question
    and removed
    bug
    on Apr 1, 2023
  3. mominul commented on Apr 1, 2023

    @mominul
    Author

    Thanks! But I think this demands a FAQ entry, many API still uses 'hinstance' as the parameter name and MSDN docs have references to HINSTANCE.

    Otherwise the metadata should get rid of 'hinstance' as parameter names also.

  4. kennykerr commented on Apr 3, 2023

    @kennykerr
    Contributor

    I'll pass this on to the Win32 metadata repo for visibility.

  5. mikebattista commented on Apr 3, 2023

    @mikebattista
    Contributor

    We can't change parameter names. When everything was HINSTANCE, the "module"-based parameters were out of sync, so if we need to standardize on 1 type for interoperability as we've done so far, the inconsistency will exist.

    That said, I'm curious if we define both HMODULE and HINSTANCE and set them as AlsoUsableFor each other, if that would address the parameter name <-> type inconsistencies while also enabling interoperability. Below is what that would change.

    [RAIIFree("FreeLibrary")]
    [AlsoUsableFor("HINSTANCE")]
    [InvalidHandleValue(0L)]
    [NativeTypedef]
    public struct HMODULE
    {
    	public IntPtr Value;
    }
    
    [RAIIFree("FreeLibrary")]
    [AlsoUsableFor("HMODULE")]
    [InvalidHandleValue(0L)]
    [NativeTypedef]
    public struct HINSTANCE
    {
    	public IntPtr Value;
    }
    
    Windows.Win32.Data.HtmlHelp.HH_POPUP.hinst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Devices.DeviceAndDriverInstallation.Apis.InstallHinfSectionA : ModuleHandle...HMODULE => HINSTANCE
    Windows.Win32.Devices.DeviceAndDriverInstallation.Apis.InstallHinfSectionW : ModuleHandle...HMODULE => HINSTANCE
    Windows.Win32.Devices.Fax.Apis.StiCreateInstanceW : hinst...HMODULE => HINSTANCE
    Windows.Win32.Devices.Fax.IStiDevice.Initialize : hinst...HMODULE => HINSTANCE
    Windows.Win32.Devices.Fax.IStillImageW.Initialize : hinst...HMODULE => HINSTANCE
    Windows.Win32.Devices.Fax.PFAX_EXT_REGISTER_FOR_EVENTS.Invoke : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.Fax.PFAX_EXT_SET_DATA.Invoke : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.Apis.DirectInput8Create : hinst...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.DIACTIONFORMATA.hInstString...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.DIACTIONFORMATW.hInstString...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInput8A.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInput8W.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputA.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputDevice8A.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputDevice8W.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputDeviceA.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputDeviceW.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputEffect.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.HumanInterfaceDevice.IDirectInputW.Initialize : param0...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.lineInitialize : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.lineInitializeExA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.lineInitializeExW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.phoneInitialize : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.phoneInitializeExA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Devices.Tapi.Apis.phoneInitializeExW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Foundation.HINSTANCE added
    Windows.Win32.Foundation.HMODULE : [InvalidHandleValue(0),NativeTypedef,RAIIFree(FreeLibrary)] => [AlsoUsableFor(HINSTANCE),InvalidHandleValue(0),NativeTypedef,RAIIFree(FreeLibrary)]
    Windows.Win32.Graphics.DirectDraw.DDRAWI_DIRECTDRAW_LCL.hD3DInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Graphics.Gdi.Apis.LoadBitmapA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Graphics.Gdi.Apis.LoadBitmapW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Graphics.Printing.COMPROPSHEETUI.hInstCaller...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Graphics.Printing.OIEXT.hInstCaller...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Graphics.Printing.PROPSHEETUI_INFO_HEADER.hInst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Media.Audio.ACMFILTERCHOOSEA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Media.Audio.ACMFILTERCHOOSEW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Media.Audio.ACMFORMATCHOOSEA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Media.Audio.ACMFORMATCHOOSEW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Media.Audio.Apis.acmDriverAddA : hinstModule...HMODULE => HINSTANCE
    Windows.Win32.Media.Audio.Apis.acmDriverAddW : hinstModule...HMODULE => HINSTANCE
    Windows.Win32.Media.Multimedia.Apis.MCIWndCreateA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Media.Multimedia.Apis.MCIWndCreateW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.Networking.ActiveDirectory.CQPAGE.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Networking.ActiveDirectory.DSQUERYPARAMS.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Networking.WinInet.Apis.DeleteIE3Cache : hinst...HMODULE => HINSTANCE
    Windows.Win32.Networking.WinInet.Apis.RunOnceUrlCache : hinst...HMODULE => HINSTANCE
    Windows.Win32.NetworkManagement.Rras.RasCustomDialDlgFn.Invoke : hInstDll...HMODULE => HINSTANCE
    Windows.Win32.NetworkManagement.Rras.RasCustomDialFn.Invoke : hInstDll...HMODULE => HINSTANCE
    Windows.Win32.NetworkManagement.Rras.RasCustomEntryDlgFn.Invoke : hInstDll...HMODULE => HINSTANCE
    Windows.Win32.Security.Authorization.UI.SI_OBJECT_INFO.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Security.Cryptography.UI.CERT_SELECT_STRUCT_A.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Security.Cryptography.UI.CERT_SELECT_STRUCT_W.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Security.Cryptography.UI.CERT_VIEWPROPERTIES_STRUCT_A.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Security.Cryptography.UI.CERT_VIEWPROPERTIES_STRUCT_W.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.AddressBook.Apis.BuildDisplayTable : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.ClrHosting.Apis.RunDll32ShimW : hinst...HMODULE => HINSTANCE
    Windows.Win32.System.Com.Apis.CoFreeLibrary : hInst...HMODULE => HINSTANCE
    Windows.Win32.System.Com.Apis.CoLoadLibrary : return...HMODULE => HINSTANCE
    Windows.Win32.System.Ole.Apis.OleIconToCursor : hinstExe...HMODULE => HINSTANCE
    Windows.Win32.System.Ole.OLEUIBUSYA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIBUSYW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICHANGEICONA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICHANGEICONW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICHANGESOURCEA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICHANGESOURCEW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICONVERTA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUICONVERTW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIEDITLINKSA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIEDITLINKSW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIINSERTOBJECTA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIINSERTOBJECTW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIPASTESPECIALA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.Ole.OLEUIPASTESPECIALW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.DelNodeRunDLL32W : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.LaunchINFSectionExW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.LaunchINFSectionW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.UserInstStubWrapperA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.UserInstStubWrapperW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.UserUnInstStubWrapperA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.System.WindowsProgramming.Apis.UserUnInstStubWrapperW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.CreateMappedBitmap : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.CreateToolbarEx : hBMInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.CreateUpDownControl : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.GetThemeStream : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.ImageList_LoadImageA : hi...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.ImageList_LoadImageW : hi...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.LoadIconMetric : hinst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.LoadIconWithScaleDown : hinst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.MenuHelp : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Apis.TaskDialog : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.CHOOSEFONTA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.CHOOSEFONTA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.CHOOSEFONTW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.CHOOSEFONTW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.FINDREPLACEA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.FINDREPLACEA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.FINDREPLACEW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.FINDREPLACEW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAME_NT4A.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAME_NT4A.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAME_NT4W.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAME_NT4W.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAMEA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAMEA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAMEW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.OPENFILENAMEW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PAGESETUPDLGA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PAGESETUPDLGA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PAGESETUPDLGW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PAGESETUPDLGW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGEXA.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGEXA.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGEXW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGEXW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGW.hInstance(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.Dialogs.PRINTDLGW.hInstance(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.NMTTDISPINFOA.hinst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.NMTTDISPINFOW.hinst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETHEADERA_V1.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETHEADERA_V2.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETHEADERW_V1.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETHEADERW_V2.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEA_V1.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEA_V2.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEA_V3.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEW_V1.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEW_V2.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEW_V3.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.PROPSHEETPAGEW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TASKDIALOGCONFIG.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TBADDBITMAP.hInst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TBREPLACEBITMAP.hInstNew...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TBREPLACEBITMAP.hInstOld...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TTTOOLINFOA.hinst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Controls.TTTOOLINFOW.hinst...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Ribbon.IUIFramework.LoadUI : instance...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.DuplicateIcon : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractAssociatedIconA : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractAssociatedIconExA : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractAssociatedIconExW : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractAssociatedIconW : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractIconA : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ExtractIconW : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.FindExecutableA : return...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.FindExecutableW : return...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ShellExecuteA : return...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ShellExecuteW : return...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ShellMessageBoxA : hAppInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.Apis.ShellMessageBoxW : hAppInst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.IProgressDialog.SetAnimation : hInstAnimation...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.PropertiesSystem.Apis.InitPropVariantFromResource : hinst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.PropertiesSystem.Apis.InitVariantFromResource : hinst...HMODULE => HINSTANCE
    Windows.Win32.UI.Shell.SHELLEXECUTEINFOA.hInstApp(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Shell.SHELLEXECUTEINFOA.hInstApp(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Shell.SHELLEXECUTEINFOW.hInstApp(X64, Arm64)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.Shell.SHELLEXECUTEINFOW.hInstApp(X86)...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateCursor : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateDialogIndirectParamA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateDialogIndirectParamW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateDialogParamA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateDialogParamW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateIcon : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateMDIWindowA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateMDIWindowW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateWindowExA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.CreateWindowExW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.DialogBoxIndirectParamA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.DialogBoxIndirectParamW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.DialogBoxParamA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.DialogBoxParamW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.GetClassInfoA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.GetClassInfoExA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.GetClassInfoExW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.GetClassInfoW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadAcceleratorsA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadAcceleratorsW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadCursorA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadCursorW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadIconA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadIconW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadImageA : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadImageW : hInst...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadMenuA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadMenuW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadStringA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.LoadStringW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.SetWindowsHookExA : hmod...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.SetWindowsHookExW : hmod...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.UnregisterClassA : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.Apis.UnregisterClassW : hInstance...HMODULE => HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.CREATESTRUCTA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.CREATESTRUCTW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.MSGBOXPARAMSA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.MSGBOXPARAMSW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.WNDCLASSA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.WNDCLASSEXA.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.WNDCLASSEXW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.UI.WindowsAndMessaging.WNDCLASSW.hInstance...Windows.Win32.Foundation.HMODULE => Windows.Win32.Foundation.HINSTANCE
    Windows.Win32.Web.InternetExplorer.Apis.RatingClickedOnPRFInternal : param1...HMODULE => HINSTANCE
    Windows.Win32.Web.InternetExplorer.Apis.RatingClickedOnRATInternal : param1...HMODULE => HINSTANCE
    
  6. added a commit that references this issue on Apr 3, 2023
    0765a0d
  7. mikebattista commented on Apr 5, 2023

    @mikebattista
    Contributor

    Should we make this change?

    Kenny Kerr (@kennykerr) Andrew Arnott (@AArnott) Tim Sneath (@timsneath) Jonathan Marler (@marler8997) do you support AlsoUsableFor in this way?

  8. timsneath commented on Apr 5, 2023

    @timsneath
    Contributor

    Dart doesn't need an attribute to differentiate between these (we treat them both as IntPtr), so no issue for us here.

  9. mikebattista commented on Apr 5, 2023

    @mikebattista
    Contributor

    As long as examples like https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-createwindowexw#example continue to work then this would be an improvement.

    The example above is passing GetModuleHandle(null), which returns an HMODULE, into CreateWindow, which expects an HINSTANCE.

  10. marler8997 commented on Apr 5, 2023

    @marler8997
    Contributor

    My unqualified opinion is that it seems like there's a new level of complexity added when your type heirachy is more complex than a DAG. I could forsee some languages possibly having problems if AlsoUsableFor could create cycles? Not sure though, just a hunch mostly. As for Zig we can't really do much with AlsoUsableFor except using it to create convenient functions for conversions so these cycles wouldn't be an issue. I think there might be a proposal around adding implicit conversions between opaque types, but I think those are "one-way" meaning the relationship would have to be a DAG. Take this all with a big grain of salt :)

  11. kennykerr commented on Apr 5, 2023

    @kennykerr
    Contributor

    do you support AlsoUsableFor in this way?

    Yes.

  12. AArnott commented on Apr 6, 2023

    @AArnott
    Member

    CsWin32 doesn't support AlsoUsableFor yet. But when it does, I don't anticipate any problems for C# if relationships were cyclical.

  13. mikebattista commented on Apr 6, 2023

    @mikebattista
    Contributor

    Thanks. So if we make this change, C# users will need to cast HMODULEs to HINSTANCEs in the meantime if they need to convert?

  14. AArnott commented on Apr 6, 2023

    @AArnott
    Member

    I don't think a cast would work. They would have to do something like new HMODULE(hinstance.Value).

  15. mikebattista commented on Apr 6, 2023

    @mikebattista
    Contributor

    Ok. I'd prefer you support the implicit conversion before we make this change.

  16. AArnott commented on Apr 6, 2023

    @AArnott
    Member

    Thanks. I'll bump the priority of adding that feature.

  17. mikebattista commented on Apr 6, 2023

    @mikebattista
    Contributor

    Thanks!

  18. added a commit that references this issue on Mar 28, 2026
    42ac479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions