locked
Windows Kits for Windows Store application problem

    Question

  • Hi,

    I'm trying to port C++ code, which worked before on Win32, to Windows Store app's DLL (it deals with Media Foundation). When I try to build DLL's project it throws an error about undefined identifier SHGDNF in ShObjIdl.h (this library is from Microsoft Windows Kits). As I discovered it happens because the SHGNF enum is declared under  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

    section (so it makes impossible to use this enum) and some methods using SHGDNF enum are not under this section and can't be built.

    So I got stucked.

    Maybe anyone knows how to solve this problem or if I do anything wrong

    Thanks in advance


    Tuesday, April 16, 2013 10:11 AM

Answers

  • Yes got it. It seems to me that any Windows Store Apps that include #include <ShObjIdl.h> will encountered the compilation error since this file contains contradictory thing. May be it's a bug. But I think you should refrain from including it and figure out a work around for it.

    By the way, earlier, I was subjected to such kind of problem. In Windows 8 Release Preview (build 8400), unfortunately _beginthreadex go out of #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP conditions. That's why you could use it in Windows Store Apps that time. But in  Windows 8 RTM this problem is resolved and _beginthreadex & its co are no longer available.


    Thursday, April 18, 2013 7:27 AM

All replies

  • If you are converting a previous *.vcxproj  project file in order to build it as Windows Store Apps, you should specify following things

    • Consume Windows Runtime component = Yes(/ZW)
    • Windows Store apps Support = yes
    • In the source code you need to define WINAPI_FAMILY as WINAPI_FAMILY_APP in order to partitioning API family before including any Windows standard header. Because by default WINAPI_FAMILY is defined by WINAPI_FAMILY_DESKTOP_APP.
    #define WINAPI_FAMILY WINAPI_FAMILY_APP 

    If you create a new project which is Windows Store Apps type through VS2012, then above option will be set automatically.

    #if WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP )
                    //Available to Desktop program. So you have to find work around here. 
            #endif

    In Windows 8 SDK which will be available after installing VS2012, MS has included a new file named winapifamily.h in windows.h header in order to partitioning API family. You can see this file for getting the scenario. Actually which code will be available to the program's target run-time platform is finally decided by the value defined in constant WINAPI_FAMILY.

    When ones open a Windows Store Apps by Visual Studio 2012 the WINAPI_FAMILY is defined by WINAPI_FAMILY_APP. Here is the summary.

    #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
           //define for typical Desktop Apps.
    #define WINAPI_FAMILY WINAPI_FAMILY_APP   
           //define for Windows Store Apps.  
    
            #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY, WINAPI_PARTITION_APP )
                    //Available only only to Metro programs.             
            #endif
    
            #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY, WINAPI_PARTITION_DESKTOP )
                    //Available only onlyto Desktop programs.
            #endif
    
            #if WINAPI_FAMILY_ONE_PARTITION( WINAPI_FAMILY_DESKTOP_APP, WINAPI_PARTITION_APP )
                    //Available to Metro, but not Desktop programs.
            #endif
    
            #if WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_APP )
                    //Available to Metro and Desktop programs.
            #endif
    
            #if WINAPI_FAMILY_PARTITION( WINAPI_PARTITION_DESKTOP )
                    //Available to Desktop program.
            #endif

    Tuesday, April 16, 2013 11:37 AM
  • Oh, thanks a lot for this information. it's really useful.

    But it doesn't solves the problem with ShObjIdl.h standart header file. Let me explain more in details:

     ShObjIdl.h contains:

    ...
    #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
    ...
    enum _SHGDNF
        {
            //enum's stuff
        } ;
    typedef DWORD SHGDNF;
    ...
    #endif
    ...
     HRESULT STDMETHODCALLTYPE IShellFolder_SetNameOf_Stub( 
        __RPC__in IShellFolder * This,
        __RPC__in_opt HWND hwnd,
        __RPC__in PCUITEMID_CHILD pidl,
        __RPC__in_string LPCWSTR pszName,
        SHGDNF uFlags,                //SHGDNF argument!
        __RPC__deref_out_opt PITEMID_CHILD *ppidlOut);
     

    Because  SHGDNF enum is declared inside WINAPI_PARTITION_DESKTOP section, when I'm trying to build Metro app, compiler skips this section. Then compiler reaches  IShellFolder_SetNameOf_Stub and, as SHGDNF indentifier is unknown, it throws an error.

    I wonder if it is  ShObjIdl.h's bug.. and in that case, am I allowed to edit this header? Or is there any better solution?

    Thursday, April 18, 2013 7:03 AM
  • Yes got it. It seems to me that any Windows Store Apps that include #include <ShObjIdl.h> will encountered the compilation error since this file contains contradictory thing. May be it's a bug. But I think you should refrain from including it and figure out a work around for it.

    By the way, earlier, I was subjected to such kind of problem. In Windows 8 Release Preview (build 8400), unfortunately _beginthreadex go out of #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP conditions. That's why you could use it in Windows Store Apps that time. But in  Windows 8 RTM this problem is resolved and _beginthreadex & its co are no longer available.


    Thursday, April 18, 2013 7:27 AM