From e7b53af398d69e088762ff9db4253bc0e7d88eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 14 Nov 2017 20:44:16 +0100 Subject: [PATCH] 2017-11-14 20:44 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbwin/hbwin.hbx * contrib/hbwin/wapi_winbase_2.c + added PRG wrapper to QueryDosDevice() WINAPI function wapi_QueryDosDevice( ) -> --- ChangeLog.txt | 6 ++++++ contrib/hbwin/hbwin.hbx | 1 + contrib/hbwin/wapi_winbase_2.c | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index c6583822cb..0be1b23a7f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,12 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2017-11-14 20:44 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbwin/hbwin.hbx + * contrib/hbwin/wapi_winbase_2.c + + added PRG wrapper to QueryDosDevice() WINAPI function + wapi_QueryDosDevice( ) -> + 2017-11-14 20:30 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rdd/dbf1.c ! fixed typo in index used inside DBS_ISNULL diff --git a/contrib/hbwin/hbwin.hbx b/contrib/hbwin/hbwin.hbx index fe8cff7ec0..0eba85b33c 100644 --- a/contrib/hbwin/hbwin.hbx +++ b/contrib/hbwin/hbwin.hbx @@ -143,6 +143,7 @@ DYNAMIC wapi_MulDiv DYNAMIC wapi_OpenMutex DYNAMIC wapi_OutputDebugString DYNAMIC wapi_PlaySound +DYNAMIC wapi_QueryDosDevice DYNAMIC wapi_QueryPerformanceCounter DYNAMIC wapi_QueryPerformanceFrequency DYNAMIC wapi_Rectangle diff --git a/contrib/hbwin/wapi_winbase_2.c b/contrib/hbwin/wapi_winbase_2.c index 9060efc9e3..b55b79543d 100644 --- a/contrib/hbwin/wapi_winbase_2.c +++ b/contrib/hbwin/wapi_winbase_2.c @@ -45,6 +45,7 @@ */ #include "hbwapi.h" +#include "hbapiitm.h" HB_FUNC( WAPI_GETLASTERROR ) { @@ -134,3 +135,37 @@ HB_FUNC( WAPI_OUTPUTDEBUGSTRING ) hb_strfree( hOutputString ); } + +#define TARGET_PATH_BUFFER_SIZE 4096 +HB_FUNC( WAPI_QUERYDOSDEVICE ) +{ + void * hDeviceName; + LPTSTR lpTargetPath = ( LPTSTR ) hb_xgrab( TARGET_PATH_BUFFER_SIZE * sizeof( TCHAR ) ); + DWORD dwResult; + + dwResult = QueryDosDevice( HB_PARSTR( 1, &hDeviceName, NULL ), lpTargetPath, TARGET_PATH_BUFFER_SIZE ); + hbwapi_SetLastError( GetLastError() ); + if( dwResult ) + { + PHB_ITEM pArray = hb_itemArrayNew( 0 ), pItem = NULL; + DWORD dwPos, dwStart; + + dwPos = dwStart = 0; + while( lpTargetPath[ dwPos ] ) + { + if( ! lpTargetPath[ ++dwPos ] ) + { + pItem = HB_ITEMPUTSTRLEN( pItem, lpTargetPath + dwStart, dwPos - dwStart - 1 ); + hb_arrayAdd( pArray, pItem ); + dwStart = ++dwPos; + } + } + hb_itemRelease( pItem ); + hb_itemReturnRelease( pArray ); + } + else + hb_reta( 0 ); + + hb_strfree( hDeviceName ); + hb_xfree( lpTargetPath ); +}