diff --git a/harbour/ChangeLog b/harbour/ChangeLog index af51c4a506..39fd38555f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,10 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-11 04:25 UTC+0100 Xavi (jarabal/at/gmail.com) + * contrib/hbwin/wapi_winbase.c + + Added wapi_GETSHORTPATHNAME() + 2010-02-10 20:23 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/achoice.prg ! fixed typo in one of recent modifications which caused RTE in diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index 847734efc6..1d93bbdc22 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -295,3 +295,36 @@ HB_FUNC( WAPI_MULDIV ) { hb_retni( MulDiv( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); } + +HB_FUNC( WAPI_GETSHORTPATHNAME ) +{ + void * hLongPath; + DWORD length = 0; + LPCTSTR lpszLongPath = HB_PARSTR( 1, &hLongPath, NULL ); + + if( lpszLongPath ) + { + length = GetShortPathName( lpszLongPath, NULL, 0 ); + + if( length && HB_ISBYREF( 2 ) ) + { + LPTSTR lpszShortPath; + DWORD cchBuffer = ( DWORD ) hb_parnl( 3 ); + + if( cchBuffer ) + cchBuffer = HB_MIN( length, cchBuffer + sizeof( TCHAR ) ); + else + cchBuffer = length; + + lpszShortPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) ); + length = GetShortPathName( lpszLongPath, lpszShortPath, cchBuffer ); + hbwapi_SetLastError( GetLastError() ); + HB_STORSTR( length > cchBuffer ? NULL : lpszShortPath, 2 ); + hb_xfree( lpszShortPath ); + } + else if( length == 0 ) + hbwapi_SetLastError( GetLastError() ); + } + hb_retnl( length ); + hb_strfree( hLongPath ); +}