2012-11-22 19:07 UTC+0100 Viktor Szakats (harbour syenar.net)
* include/hbwinuni.h
+ added HB_WINAPI_FUNCTION_NAME() macro to form a WinAPI
function name as a string (for dynamic calls)
Thanks to Mindaugas for the idea.
* contrib/hbwin/wapi_winbase.c
* contrib/hbwin/wapi_wingdi_font.c
* contrib/hbwin/win_prn2.c
* contrib/hbwin/win_prn3.c
* contrib/hbwin/win_rpc.c
* src/rtl/diskspac.c
* src/rtl/disksphb.c
* src/rtl/fslink.c
% eliminated few UNICODE build-time branches by using
new HB_WINAPI_FUNCTION_NAME() macro
This commit is contained in:
@@ -10,6 +10,24 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2012-11-22 19:07 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* include/hbwinuni.h
|
||||
+ added HB_WINAPI_FUNCTION_NAME() macro to form a WinAPI
|
||||
function name as a string (for dynamic calls)
|
||||
Thanks to Mindaugas for the idea.
|
||||
|
||||
* contrib/hbwin/wapi_winbase.c
|
||||
* contrib/hbwin/wapi_wingdi_font.c
|
||||
* contrib/hbwin/win_prn2.c
|
||||
* contrib/hbwin/win_prn3.c
|
||||
* contrib/hbwin/win_rpc.c
|
||||
* src/rtl/diskspac.c
|
||||
* src/rtl/disksphb.c
|
||||
* src/rtl/fslink.c
|
||||
% eliminated few UNICODE build-time branches by using
|
||||
new HB_WINAPI_FUNCTION_NAME() macro
|
||||
(non-UNICODE branch not tested)
|
||||
|
||||
2012-11-22 18:46 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/hbct/doc/en/atadjust.txt
|
||||
* contrib/hbct/doc/en/color.txt
|
||||
|
||||
@@ -383,14 +383,16 @@ HB_FUNC( WAPI_GETLONGPATHNAME )
|
||||
|
||||
if( ! s_getPathNameAddr )
|
||||
{
|
||||
s_getPathNameAddr = ( _HB_GETPATHNAME )
|
||||
s_getPathNameAddr =
|
||||
( _HB_GETPATHNAME )
|
||||
GetProcAddress(
|
||||
#if defined( UNICODE )
|
||||
GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
"GetLongPathNameW" );
|
||||
GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
#else
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
"GetLongPathNameA" );
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "GetLongPathName" ) );
|
||||
|
||||
if( ! s_getPathNameAddr )
|
||||
s_getPathNameAddr = GetShortPathName;
|
||||
}
|
||||
|
||||
@@ -80,11 +80,7 @@ HB_FUNC( WAPI_ADDFONTRESOURCEEX )
|
||||
|
||||
if( ! s_pAddFontResourceEx )
|
||||
s_pAddFontResourceEx = ( _HB_ADDFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ),
|
||||
#if defined( UNICODE )
|
||||
"AddFontResourceExW" );
|
||||
#else
|
||||
"AddFontResourceExA" );
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "AddFontResourceEx" ) );
|
||||
|
||||
if( s_pAddFontResourceEx )
|
||||
{
|
||||
@@ -110,11 +106,7 @@ HB_FUNC( WAPI_REMOVEFONTRESOURCEEX )
|
||||
|
||||
if( ! s_pRemoveFontResourceEx )
|
||||
s_pRemoveFontResourceEx = ( _HB_REMOVEFONTRESOURCEEX ) GetProcAddress( GetModuleHandle( TEXT( "gdi32.dll" ) ),
|
||||
#if defined( UNICODE )
|
||||
"RemoveFontResourceExW" );
|
||||
#else
|
||||
"RemoveFontResourceExA" );
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "RemoveFontResourceEx" ) );
|
||||
|
||||
if( s_pRemoveFontResourceEx )
|
||||
{
|
||||
|
||||
@@ -137,11 +137,7 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName )
|
||||
if( hWinSpool )
|
||||
{
|
||||
fnGetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool,
|
||||
#if defined( UNICODE )
|
||||
"GetDefaultPrinterW" );
|
||||
#else
|
||||
"GetDefaultPrinterA" );
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "GetDefaultPrinter" ) );
|
||||
|
||||
if( fnGetDefaultPrinter )
|
||||
{
|
||||
|
||||
@@ -128,12 +128,10 @@ static HB_BOOL hb_SetDefaultPrinter( LPCTSTR lpPrinterName )
|
||||
hWinSpool = hbwapi_LoadLibrarySystem( TEXT( "winspool.drv" ) );
|
||||
if( ! hWinSpool )
|
||||
return HB_FALSE;
|
||||
|
||||
fnSetDefaultPrinter = ( DEFPRINTER ) GetProcAddress( hWinSpool,
|
||||
#if defined( UNICODE )
|
||||
"SetDefaultPrinterW" );
|
||||
#else
|
||||
"SetDefaultPrinterA" );
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "SetDefaultPrinter" ) );
|
||||
|
||||
if( ! fnSetDefaultPrinter )
|
||||
{
|
||||
FreeLibrary( hWinSpool );
|
||||
|
||||
@@ -78,19 +78,8 @@ HB_FUNC( WIN_UUIDCREATESTRING )
|
||||
|
||||
s_pUuidCreate = ( _HB_UUIDCREATE ) GetProcAddress( hRpcrt4, "UuidCreate" );
|
||||
|
||||
s_pUuidToString = ( _HB_UUIDTOSTRING ) GetProcAddress( hRpcrt4,
|
||||
#if defined( UNICODE )
|
||||
"UuidToStringW" );
|
||||
#else
|
||||
"UuidToStringA" );
|
||||
#endif
|
||||
|
||||
s_pRpcStringFree = ( _HB_RPCSTRINGFREE ) GetProcAddress( hRpcrt4,
|
||||
#if defined( UNICODE )
|
||||
"RpcStringFreeW" );
|
||||
#else
|
||||
"RpcStringFreeA" );
|
||||
#endif
|
||||
s_pUuidToString = ( _HB_UUIDTOSTRING ) GetProcAddress( hRpcrt4, HB_WINAPI_FUNCTION_NAME( "UuidToString" ) );
|
||||
s_pRpcStringFree = ( _HB_RPCSTRINGFREE ) GetProcAddress( hRpcrt4, HB_WINAPI_FUNCTION_NAME( "RpcStringFree" ) );
|
||||
}
|
||||
|
||||
if( s_pUuidCreate &&
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
#define HB_CHARDUPN( str, len ) hb_osStrU16EncodeN( str, len )
|
||||
#define HB_OSSTRDUP( str ) hb_osStrU16Decode( str )
|
||||
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrU16Decode2( str, buf, len )
|
||||
#define HB_WINAPI_FUNCTION_NAME( a ) ( a "W" )
|
||||
#else
|
||||
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
|
||||
#define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) )
|
||||
@@ -119,6 +120,7 @@
|
||||
#define HB_CHARDUPN( str, len ) hb_osStrEncodeN( str, len )
|
||||
#define HB_OSSTRDUP( str ) hb_osStrDecode( str )
|
||||
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrDecode2( str, buf, len )
|
||||
#define HB_WINAPI_FUNCTION_NAME( a ) ( a "A" )
|
||||
#endif
|
||||
|
||||
#endif /* HB_OS_WIN */
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
# endif
|
||||
#elif defined( HB_OS_WIN )
|
||||
# include <windows.h>
|
||||
# include "hbwinuni.h"
|
||||
# if defined( HB_OS_WIN_CE )
|
||||
# include "hbwince.h"
|
||||
# endif
|
||||
@@ -166,14 +167,15 @@ HB_FUNC( DISKSPACE )
|
||||
|
||||
if( ! s_fInit )
|
||||
{
|
||||
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
|
||||
s_pGetDiskFreeSpaceEx =
|
||||
( P_GDFSE )
|
||||
GetProcAddress(
|
||||
#if defined( UNICODE )
|
||||
GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
"GetDiskFreeSpaceExW" );
|
||||
GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
#else
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
"GetDiskFreeSpaceExA" );
|
||||
GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "GetDiskFreeSpaceEx" ) );
|
||||
s_fInit = HB_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,14 +126,16 @@ HB_FUNC( HB_DISKSPACE )
|
||||
|
||||
if( ! s_fInit )
|
||||
{
|
||||
s_pGetDiskFreeSpaceEx = ( P_GDFSE )
|
||||
s_pGetDiskFreeSpaceEx =
|
||||
( P_GDFSE )
|
||||
GetProcAddress(
|
||||
#if defined( UNICODE )
|
||||
GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
"GetDiskFreeSpaceExW" );
|
||||
GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ),
|
||||
#else
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
"GetDiskFreeSpaceExA" );
|
||||
GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#endif
|
||||
HB_WINAPI_FUNCTION_NAME( "GetDiskFreeSpaceEx" ) );
|
||||
|
||||
s_fInit = HB_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,10 @@ HB_BOOL hb_fsLink( const char * pszExisting, const char * pszNewFile )
|
||||
static _HB_CREATEHARDLINK s_pCreateHardLink = NULL;
|
||||
|
||||
if( ! s_pCreateHardLink )
|
||||
s_pCreateHardLink = ( _HB_CREATEHARDLINK ) GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#if defined( UNICODE )
|
||||
"CreateHardLinkW" );
|
||||
#else
|
||||
"CreateHardLinkA" );
|
||||
#endif
|
||||
s_pCreateHardLink =
|
||||
( _HB_CREATEHARDLINK )
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
HB_WINAPI_FUNCTION_NAME( "CreateHardLink" ) );
|
||||
|
||||
if( s_pCreateHardLink )
|
||||
{
|
||||
@@ -163,12 +161,10 @@ HB_BOOL hb_fsLinkSym( const char * pszTarget, const char * pszNewFile )
|
||||
#endif
|
||||
|
||||
if( ! s_pCreateSymbolicLink )
|
||||
s_pCreateSymbolicLink = ( _HB_CREATESYMBOLICLINK ) GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#if defined( UNICODE )
|
||||
"CreateSymbolicLinkW" );
|
||||
#else
|
||||
"CreateSymbolicLinkA" );
|
||||
#endif
|
||||
s_pCreateSymbolicLink =
|
||||
( _HB_CREATESYMBOLICLINK )
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
HB_WINAPI_FUNCTION_NAME( "CreateSymbolicLink" ) );
|
||||
|
||||
if( s_pCreateSymbolicLink )
|
||||
{
|
||||
@@ -269,12 +265,10 @@ char * hb_fsLinkRead( const char * pszFile )
|
||||
#endif
|
||||
|
||||
if( ! s_pGetFinalPathNameByHandle )
|
||||
s_pGetFinalPathNameByHandle = ( _HB_GETFINALPATHNAMEBYHANDLE ) GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
#if defined( UNICODE )
|
||||
"GetFinalPathNameByHandleW" );
|
||||
#else
|
||||
"GetFinalPathNameByHandleA" );
|
||||
#endif
|
||||
s_pGetFinalPathNameByHandle =
|
||||
( _HB_GETFINALPATHNAMEBYHANDLE )
|
||||
GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ),
|
||||
HB_WINAPI_FUNCTION_NAME( "GetFinalPathNameByHandle" ) );
|
||||
|
||||
if( s_pGetFinalPathNameByHandle )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user