Nov 142007
 

ShGetFileInfo helps us in finding out whether a given path is shared or not.

A wrapper function is given below…

bool IsPathShared( LPCTSTR lpctszPath_i )
{
   SHFILEINFO shFileInfo = { 0 };
   return ( SHGetFileInfo( lpctszPath_i,
                           0,
                           &shFileInfo,
                           sizeof( shFileInfo ),
                           SHGFI_ATTRIBUTES ) && ( shFileInfo.dwAttributes & SFGAO_SHARE ) == SFGAO_SHARE );
}// End IsPathShared

The key to this is the flag SFGAO_SHARE and SHGFI_ATTRIBUTES.

Cool isn’t it? 8)

Nov 142007
 

ShGetFileInfo is the API that helps in finding out whether a file is a shortcut to some other file.

Here is wrapper function…

bool IsShortcut( LPCTSTR lpctszPath_i )
{
    SHFILEINFO shFileInfo = { 0 };
    return (( SHGetFileInfo( lpctszPath_i,
                             0,
                             &shFileInfo,
                             sizeof( shFileInfo ),
                             SHGFI_ATTRIBUTES )) && ( shFileInfo.dwAttributes & SFGAO_LINK ) == SFGAO_LINK );
}// End IsShortcut

Cool isn’t it? 8)