HINSTANCE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mphanke

    HINSTANCE

    Hi,

    how do I get the HINSTANCE for an .NET application?
    ExtractAssociat edIcon always complains about an missing pointer reference...

    Regards,

    Martin
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: HINSTANCE

    mphanke,

    I am curious, why not use SHGetFile info? It will get the icon
    associated with a file, and take into account shell handlers and the like
    (unlike ExtractAssociat edIcon). Also, you don't need an application handle.

    If you still want to get the HINSTANCE, then you will have to get a
    module from the application (through a call to the GetModule or GetModules
    method on the Assembly class) and pass that to the static GetHINSTANCE
    method on the Marshal class.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "mphanke" <mphanke@nospam .nospam> wrote in message
    news:OO46UiBwEH A.3088@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi,
    >
    > how do I get the HINSTANCE for an .NET application?
    > ExtractAssociat edIcon always complains about an missing pointer
    > reference...
    >
    > Regards,
    >
    > Martin[/color]


    Comment

    • mphanke

      #3
      Re: HINSTANCE

      Hi,

      I tried your way - the problem was the file was on a Server and this
      didn't work, as long as the file is stored locally there is no problem.
      Look at the "Retrieve File Icon from Registry"-thread, I posted some source.

      Thanks for your hint though this really helped me!
      Regards,

      Martin

      Nicholas Paldino [.NET/C# MVP] wrote:
      [color=blue]
      > mphanke,
      >
      > I am curious, why not use SHGetFile info? It will get the icon
      > associated with a file, and take into account shell handlers and the like
      > (unlike ExtractAssociat edIcon). Also, you don't need an application handle.
      >
      > If you still want to get the HINSTANCE, then you will have to get a
      > module from the application (through a call to the GetModule or GetModules
      > method on the Assembly class) and pass that to the static GetHINSTANCE
      > method on the Marshal class.
      >
      > Hope this helps.
      >
      >[/color]

      Comment

      Working...