locked
Equaivalent of GetModuleHandle and GetProcAddress in Metro?

    Question

  • In the desktop environment, you can use GetModuleHandle and GetProcAddress to find the version of the VC RTL that the application uses and then to find things like
    “_errno”.  We do this in order to have a single version of an RTL that works with all versions of the VC++ RTL.  Is there a way to do this in Metro?
    • Moved by Helen Zhao Wednesday, April 25, 2012 4:27 AM (From:Visual C++ General)
    Monday, April 23, 2012 4:22 PM

Answers

  • GetProcAddress is supported in Metro apps. GetModuleHandle isn't, the closest function you can use is LoadPackagedLibrary: http://msdn.microsoft.com/en-us/library/windows/desktop/hh447159(v=vs.85).aspx

    "We do this in order to have a single version of an RTL that works with all versions of the VC++ RTL.  Is there a way to do this in Metro?"

    I'm not sure what you are trying to do but as things are now Metro apps will only use version 11 or the C runtime, you can't make Metro apps with earlier versions of VC++.

    • Marked as answer by Jesse Jiang Monday, May 7, 2012 2:35 AM
    Monday, April 23, 2012 4:45 PM
  • The thing to remember is that if you use something that is not allowed by Metro then you can't get your application certified and it can't go onto the store when it is released.

    This topic lists the Win32 API functions that are allowed, and as you can see, GetModuleHandle isn't allowed. (You can see this when you look at the function reference for GetModuleHandle too) so it is disallowed in Metro. There also doesn't seem to be any alternative from what I have seen.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Do you want Visual Studio 11 Express to be freely installable on Windows 7 and able to write regular C++ applications? Please vote for this.

    • Marked as answer by Jesse Jiang Monday, May 7, 2012 2:35 AM
    Monday, April 23, 2012 4:51 PM

All replies

  • GetProcAddress is supported in Metro apps. GetModuleHandle isn't, the closest function you can use is LoadPackagedLibrary: http://msdn.microsoft.com/en-us/library/windows/desktop/hh447159(v=vs.85).aspx

    "We do this in order to have a single version of an RTL that works with all versions of the VC++ RTL.  Is there a way to do this in Metro?"

    I'm not sure what you are trying to do but as things are now Metro apps will only use version 11 or the C runtime, you can't make Metro apps with earlier versions of VC++.

    • Marked as answer by Jesse Jiang Monday, May 7, 2012 2:35 AM
    Monday, April 23, 2012 4:45 PM
  • The thing to remember is that if you use something that is not allowed by Metro then you can't get your application certified and it can't go onto the store when it is released.

    This topic lists the Win32 API functions that are allowed, and as you can see, GetModuleHandle isn't allowed. (You can see this when you look at the function reference for GetModuleHandle too) so it is disallowed in Metro. There also doesn't seem to be any alternative from what I have seen.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Do you want Visual Studio 11 Express to be freely installable on Windows 7 and able to write regular C++ applications? Please vote for this.

    • Marked as answer by Jesse Jiang Monday, May 7, 2012 2:35 AM
    Monday, April 23, 2012 4:51 PM
  • Hi Devinder,

    According to your description, I'd like to move this thread to Building Metro style apps with C++ Forum for better support.

    Thanks for your understanding.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, April 25, 2012 4:27 AM