コード例 #1
0
ファイル: win_dlg.c プロジェクト: JamesLinus/core
static void s_GetFileName( HB_BOOL fSave )
{
   void * hInitDir, * hTitle, * hDefExt;
   LPTSTR lpstrFilter;
   OPENFILENAME ofn;

   memset( &ofn, 0, sizeof( ofn ) );
#if defined( OPENFILENAME_SIZE_VERSION_400 )
   ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
#else
   ofn.lStructSize = sizeof( ofn );
#endif
   ofn.hwndOwner = GetActiveWindow();
   ofn.hInstance = GetModuleHandle( NULL );

   ofn.nFilterIndex     = hbwapi_par_DWORD( 6 );
   ofn.lpstrFilter      = lpstrFilter = s_dialogPairs( 5, &ofn.nFilterIndex );

   ofn.nMaxFile         = hbwapi_par_DWORD( 7 );
   if( ofn.nMaxFile < 0x400 )
      ofn.nMaxFile = ofn.nMaxFile == 0 ? 0x10000 : 0x400;
   ofn.lpstrFile        = ( LPTSTR )
                          memset( hb_xgrab( ofn.nMaxFile * sizeof( TCHAR ) ),
                                  0, ofn.nMaxFile * sizeof( TCHAR ) );

   ofn.lpstrInitialDir  = HB_PARSTR( 3, &hInitDir, NULL );
   ofn.lpstrTitle       = HB_PARSTR( 2, &hTitle, NULL );
   ofn.Flags            = HB_ISNUM( 1 ) ? hbwapi_par_DWORD( 1 ) :
                          ( OFN_EXPLORER | OFN_ALLOWMULTISELECT |
                            OFN_HIDEREADONLY | OFN_NOCHANGEDIR );
   ofn.lpstrDefExt      = HB_PARSTR( 4, &hDefExt, NULL );
   if( ofn.lpstrDefExt && ofn.lpstrDefExt[ 0 ] == '.' )
      ++ofn.lpstrDefExt;

   HB_ITEMCOPYSTR( hb_param( 8, HB_IT_ANY ), ofn.lpstrFile, ofn.nMaxFile );

   if( fSave ? GetSaveFileName( &ofn ) : GetOpenFileName( &ofn ) )
   {
      HB_SIZE nLen;
      for( nLen = 0; nLen < ofn.nMaxFile; ++nLen )
      {
         if( ofn.lpstrFile[ nLen ] == 0 &&
             ( nLen + 1 == ofn.nMaxFile || ofn.lpstrFile[ nLen + 1 ] == 0 ) )
            break;
      }
      hb_stornint( ofn.Flags, 1 );
      hb_stornint( ofn.nFilterIndex, 6 );
      HB_RETSTRLEN( ofn.lpstrFile, nLen );
   }
   else
      hb_retc_null();

   hb_xfree( ofn.lpstrFile );
   if( lpstrFilter )
      hb_xfree( lpstrFilter );

   hb_strfree( hInitDir );
   hb_strfree( hTitle );
   hb_strfree( hDefExt );
}
コード例 #2
0
static void s_getPathName( _HB_GETPATHNAME getPathName )
{
   void * hLongPath;
   DWORD length = 0;
   LPCTSTR lpszLongPath = HB_PARSTR( 1, &hLongPath, NULL );

   if( lpszLongPath )
   {
      if( HB_ISBYREF( 2 ) )
      {
         TCHAR buffer[ HB_PATH_MAX ];
         DWORD cchBuffer = ( DWORD ) HB_SIZEOFARRAY( buffer );
         LPTSTR lpszShortPath = buffer;
         HB_BOOL fSize = HB_ISNUM( 3 );

         if( fSize )    /* the size of buffer is limited by user */
         {
            cchBuffer = ( DWORD ) hb_parnl( 3 );
            if( cchBuffer == 0 )
               lpszShortPath = NULL;
            else if( cchBuffer > ( DWORD ) HB_SIZEOFARRAY( buffer ) )
               lpszShortPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) );
         }

         length = getPathName( lpszLongPath, lpszShortPath, cchBuffer );
         if( ! fSize && length > cchBuffer )  /* default buffer size was too small */
         {
            cchBuffer = length;
            lpszShortPath = ( LPTSTR ) hb_xgrab( cchBuffer * sizeof( TCHAR ) );
            length = getPathName( lpszLongPath, lpszShortPath, cchBuffer );
         }
         hbwapi_SetLastError( GetLastError() );
         HB_STORSTRLEN( lpszShortPath, length > cchBuffer ? 0 : length, 2 );
         if( lpszShortPath && lpszShortPath != buffer )
            hb_xfree( lpszShortPath );
      }
      else if( getPathName )
      {
         length = getPathName( lpszLongPath, NULL, 0 );
         hbwapi_SetLastError( GetLastError() );
      }
   }
   hb_retnl( length );
   hb_strfree( hLongPath );
}
コード例 #3
0
ファイル: blatwrp.c プロジェクト: Petewg/V-harbour-core
   HB_EXTERN_END
#endif

HB_FUNC( HB_BLATSEND )
{
   if( HB_ISCHAR( 1 ) )
   {
#if defined( HBMK_HAS_BLAT )
      void * hCmdLine = NULL;
      hb_retni( cSend( HB_PARSTR( 1, &hCmdLine, NULL ) ) );
      hb_strfree( hCmdLine );
#else
      hb_retni( cSend( hb_parc( 1 ) ) );
#endif
   }
   else
      hb_errRT_BASE_SubstR( EG_ARG, 0, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}