2009-11-23 02:13 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* src/rtl/diskspac.c
  * src/rtl/disksphb.c
  * contrib/hbwin/win_prn2.c
    ! Fixed to use WIDE version of dynamically called
      functions in UNICODE builds.

  * ChangeLog
    + TODO marked as DONE.
This commit is contained in:
Viktor Szakats
2009-11-23 01:14:54 +00:00
parent e23934c9ce
commit c0df906c25
4 changed files with 139 additions and 111 deletions

View File

@@ -17,6 +17,16 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-11-23 02:13 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/diskspac.c
* src/rtl/disksphb.c
* contrib/hbwin/win_prn2.c
! Fixed to use WIDE version of dynamically called
functions in UNICODE builds.
* ChangeLog
+ TODO marked as DONE.
2009-11-23 01:24 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_prn2.c
+ Added support for fifth 'share' element to GETPRINTERS()
@@ -1782,12 +1792,12 @@
; TODO: Rename variables to reflect new type. [DONE]
; TODO: Change internal error code from ULONG to HB_ERRCODE. [DONE]
; TODO: Inspect rest of Harbour like above. I've only dealt with
rtl, vm.
rtl, vm. [DONE]
; TODO: hbnetio protocol needs to be modified to pass errcode
as 32 bit value. [DONE]
; NOTE: There is still disagreement in code in few places
in error type and 'int' is used internally, f.e.
sockets, some internal OS code conversion funtions.
sockets, some internal OS code conversion funtions. [OK]
; TODO: Different topic, but we use a lot of USHORTs to
store modes, tries, severity, operation, flags and
few other things which would better be stored as
@@ -7673,7 +7683,7 @@
so any mistakes can be deadly.
; TODO: Remaining dynamic versions, although maybe for dynamically
loaded win API functions it's better to stay with ANSI
version for compatibility.
version for compatibility. [DONE]
2009-10-15 17:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rdd/dbfcdx/dbfcdx1.c

View File

@@ -138,16 +138,28 @@ static HB_BOOL hb_GetDefaultPrinter( char * pszPrinterName, HB_SIZE * pulBufferS
if( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 5 ) /* Windows 2000 or later */
{
typedef BOOL( WINAPI * DEFPRINTER ) ( LPSTR, LPDWORD );
typedef BOOL( WINAPI * DEFPRINTER ) ( LPTSTR, LPDWORD );
DEFPRINTER fnGetDefaultPrinter;
HMODULE hWinSpool = LoadLibrary( TEXT( "winspool.drv" ) );
if( hWinSpool )
{
#if defined( UNICODE )
fnGetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool, "GetDefaultPrinterW" );
#else
fnGetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool, "GetDefaultPrinterA" );
#endif
if( fnGetDefaultPrinter )
bResult = ( *fnGetDefaultPrinter )( pszPrinterName, pulBufferSize );
{
LPTSTR lpPrinterName = ( LPTSTR ) hb_xgrab( *pulBufferSize * sizeof( TCHAR ) );
bResult = ( *fnGetDefaultPrinter )( lpPrinterName, pulBufferSize );
HB_TCHAR_GETFROM( pszPrinterName, lpPrinterName, *pulBufferSize );
hb_xfree( lpPrinterName );
}
FreeLibrary( hWinSpool );
}

View File

@@ -115,14 +115,11 @@ HB_FUNC( DISKSPACE )
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif
typedef BOOL ( WINAPI * P_GDFSE )( LPCSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
USHORT uiParam = ( USHORT ) hb_parni( 1 );
USHORT uiDrive = uiParam == 0 ? hb_fsCurDrv() + 1 : uiParam;
UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
#if defined( HB_OS_WIN_CE )
TCHAR lpPath[ 4 ];
lpPath[ 0 ] = ( TCHAR ) ( uiDrive + 'A' - 1 );
@@ -130,51 +127,52 @@ HB_FUNC( DISKSPACE )
lpPath[ 2 ] = '\\';
lpPath[ 3 ] = '\0';
bError = !GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
if( !bError )
#if defined( HB_OS_WIN_CE )
bError = ! GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
if( ! bError )
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
#else
char szPath[ 4 ];
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExA" );
szPath[ 0 ] = ( char ) uiDrive + 'A' - 1;
szPath[ 1 ] = ':';
szPath[ 2 ] = '\\';
szPath[ 3 ] = '\0';
if( pGetDiskFreeSpaceEx )
{
bError = !pGetDiskFreeSpaceEx( szPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
if( !bError )
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
}
else
{
LPTSTR lpPath = HB_TCHAR_CONVTO( szPath );
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
"GetDiskFreeSpaceExW" );
#else
"GetDiskFreeSpaceExA" );
#endif
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
if( pGetDiskFreeSpaceEx )
{
bError = ! pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
if( ! bError )
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
}
else
{
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
bError = ! GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters );
if( !bError )
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
HB_TCHAR_FREE( lpPath );
bError = ! GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters );
if( !bError )
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
}
}
#endif
SetErrorMode( uiErrMode );

View File

@@ -166,24 +166,22 @@ HB_FUNC( HB_DISKSPACE )
( ( ( double ) 0xFFFFFFFF ) + 1 ) )
#endif
typedef BOOL ( WINAPI * P_GDFSE )( LPCSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
for( ;; )
{
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS );
BOOL fResult;
#if defined( HB_OS_WIN_CE )
LPTSTR lpPath = HB_TCHAR_CONVTO( szPath );
#if defined( HB_OS_WIN_CE )
fResult = GetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
hb_fsSetIOError( fResult, 0 );
HB_TCHAR_FREE( lpPath );
if( fResult )
{
switch( uiType )
@@ -207,81 +205,91 @@ HB_FUNC( HB_DISKSPACE )
}
}
#else
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
"GetDiskFreeSpaceExA" );
if( pGetDiskFreeSpaceEx )
{
fResult = pGetDiskFreeSpaceEx( szPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
hb_fsSetIOError( fResult, 0 );
if( fResult )
typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER,
PULARGE_INTEGER, PULARGE_INTEGER );
P_GDFSE pGetDiskFreeSpaceEx = ( P_GDFSE )
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
#if defined( UNICODE )
"GetDiskFreeSpaceExW" );
#else
"GetDiskFreeSpaceExA" );
#endif
if( pGetDiskFreeSpaceEx )
{
switch( uiType )
fResult = pGetDiskFreeSpaceEx( lpPath,
( PULARGE_INTEGER ) &i64FreeBytesToCaller,
( PULARGE_INTEGER ) &i64TotalBytes,
( PULARGE_INTEGER ) &i64FreeBytes );
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
case HB_DISK_AVAIL:
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
break;
switch( uiType )
{
case HB_DISK_AVAIL:
dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller );
break;
case HB_DISK_FREE:
dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_FREE:
dSpace = HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_TOTAL:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
break;
case HB_DISK_TOTAL:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes );
break;
case HB_DISK_USED:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
HB_GET_LARGE_UINT( i64FreeBytes );
break;
case HB_DISK_USED:
dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) -
HB_GET_LARGE_UINT( i64FreeBytes );
break;
}
}
}
}
else
{
LPTSTR lpPath = HB_TCHAR_CONVTO( szPath );
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters );
hb_fsSetIOError( fResult, 0 );
HB_TCHAR_FREE( lpPath );
if( fResult )
else
{
switch( uiType )
DWORD dwSectorsPerCluster;
DWORD dwBytesPerSector;
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters );
hb_fsSetIOError( fResult, 0 );
if( fResult )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
switch( uiType )
{
case HB_DISK_AVAIL:
case HB_DISK_FREE:
dSpace = ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) dwNumberOfFreeClusters *
case HB_DISK_USED:
case HB_DISK_TOTAL:
dSpace = ( double ) dwTotalNumberOfClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
if( uiType == HB_DISK_USED )
dSpace -= ( double ) dwNumberOfFreeClusters *
( double ) dwSectorsPerCluster *
( double ) dwBytesPerSector;
break;
}
}
}
}
#endif
HB_TCHAR_FREE( lpPath );
SetErrorMode( uiErrMode );
break;
}