Thanks Viktor,
IMHO before we need to know how to set the minimum version of Windows.
Usually this is done by defining in the final project _WIN32_WINNT.
So the code would look something like this .-
...
#if ( _WIN32_WINNT >= 0x0500 ) && ! defined( HB_OS_WIN_CE )
# define HBDI_L_FGPN( p1, p2, p3 ) GetLongPathName( p1, p2, p3 )
# define HBDI_S_FGPN( p1, p2, p3 ) GetShortPathName( p1, p2, p3 )
#else
# define HBDI_L_FGPN( p1, p2, p3 ) GetShortPathName( p1, p2, p3 )
# define HBDI_S_FGPN( p1, p2, p3 ) GetShortPathName( p1, p2, p3 )
#endif
static DWORD hbi_GetShortLongPathName( HB_BOOL bLong )
{
void * hPath;
DWORD length = 0;
LPCTSTR lpszInPath = HB_PARSTR( 1, &hPath, NULL );
if( lpszInPath )
{
if( HB_ISBYREF( 2 ) )
{
TCHAR buffer[ HB_PATH_MAX ];
DWORD cchBuffer = ( DWORD ) HB_SIZEOFARRAY( buffer );
LPTSTR lpszOutPath = buffer;
HB_BOOL fSize = HB_ISNUM( 3 );
if( fSize ) /* size fixed by user */
{
cchBuffer = ( DWORD ) hb_parnl( 3 );
if( cchBuffer == 0 )
lpszOutPath = NULL;
else if( cchBuffer > ( DWORD ) HB_SIZEOFARRAY( buffer ) )
lpszOutPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) );
}
length = bLong ? HBDI_L_FGPN( lpszInPath, lpszOutPath, cchBuffer ) :
HBDI_S_FGPN( lpszInPath, lpszOutPath, cchBuffer ) ;
if( !fSize && length > cchBuffer ) /* default buffer size was too
small */
{
cchBuffer = length;
lpszOutPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) );
length = bLong ? HBDI_L_FGPN( lpszInPath, lpszOutPath, cchBuffer ) :
HBDI_S_FGPN( lpszInPath, lpszOutPath, cchBuffer ) ;
}
hbwapi_SetLastError( GetLastError() );
HB_STORSTRLEN( lpszOutPath, length > cchBuffer ? 0 : length, 2 );
if( lpszOutPath && lpszOutPath != buffer )
hb_xfree( lpszOutPath );
}
else
{
length = bLong ? HBDI_L_FGPN( lpszInPath, NULL, 0 ) :
HBDI_S_FGPN( lpszInPath, NULL, 0 ) ;
hbwapi_SetLastError( GetLastError() );
}
}
hb_strfree( hPath );
return length;
}
HB_FUNC( WAPI_GETLONGPATHNAME )
{
#if ( _WIN32_WINNT >= 0x0500 ) && ! defined( HB_OS_WIN_CE )
hb_retnl( hbi_GetShortLongPathName( HB_TRUE ) );
#else
hbwapi_SetLastError( ERROR_INVALID_FUNCTION );
hb_retnl( 0 );
#endif
}
HB_FUNC( WAPI_GETSHORTPATHNAME )
{
hbi_GetShortLongPathName( HB_FALSE );
}
...
I think we can not fix this definition inside Harbor should be passed by the
user.
What do you think about this?
Best regards,
Xavi
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour