¿Como saber el path de una tarjeta SD?

¿Como saber el path de una tarjeta SD?

Postby tsales » Tue Jan 09, 2007 7:36 pm

Amigos
Existe alguna función que devuelva el path de las tarjetas de almacenamiento (Storage Card) que tiene una PDA??
Gracias de antemano.
Saludos
Toni Sales
tsales
 
Posts: 186
Joined: Sat Oct 08, 2005 7:32 am

Postby jlcapel » Tue Jan 09, 2007 10:33 pm

Toni,

Creo que hice algo hace algún tiempo sobre este tema. Si quieres, mañana lo podemos comentar.

Saludos,
José Luis Capel
User avatar
jlcapel
 
Posts: 229
Joined: Wed Oct 12, 2005 5:32 pm
Location: Valencia - España

Postby jlcapel » Wed Jan 10, 2007 6:11 pm

Hola,

Os dejo una función que devuelve todas las tarjetas y volúmenes de una PDA.


Code: Select all  Expand view
function Main()

LOCAL a

a := PPCSDCARDS()

Aeval(a, {|n | MsgInfo( n ) } )

RETURN NIL

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbvm.h>
#include <windows.h>
#include <aygshell.h>
#include <hbapiitm.h>
#include "wininet.h"


HB_FUNC( PPCSDCARDS )
{



PHB_ITEM  sdCards;
PHB_ITEM  sdCard;
LPSTR     vMsg;

int index;

// Total number of storage cards found.
int iNumOfFlashCard = 0;

// Maximum number of storage cards to find.
int iMaxCards = 10;
// Whether to continue searching after finding a card.
BOOL bContinue = TRUE;
// Root directory path of storage cards.
TCHAR szRootDirPath[MAX_PATH];
// String for storing the storage card name with the full path.
CHAR szSCName[MAX_PATH];
// Search handle for storage cards.
HANDLE hFlashCard;
// Structure for storing card information.
WIN32_FIND_DATA *lpwfdFlashCard;
// Structure for storing card information temporarily.
WIN32_FIND_DATA *lpwfdFlashCardTmp;
lpwfdFlashCardTmp = (WIN32_FIND_DATA *) LocalAlloc
                    (LPTR, iMaxCards * sizeof (WIN32_FIND_DATA));
// Test for failed memory allocation.
if (lpwfdFlashCardTmp == NULL)
   return;
hFlashCard = FindFirstFlashCard (&lpwfdFlashCardTmp [0]);
if (hFlashCard == INVALID_HANDLE_VALUE)
{
// Free the memory.
   LocalFree (lpwfdFlashCardTmp);
   return;
}
while (bContinue)
{
   iNumOfFlashCard += 1;
   // Search for the next storage card.
   bContinue = FindNextFlashCard (hFlashCard,
               &lpwfdFlashCardTmp [iNumOfFlashCard]);
}
// Close the search handle.
FindClose (hFlashCard);

sdCards = hb_itemArrayNew( iNumOfFlashCard ) ;
sdCard  = hb_itemNew( NULL );

if (iNumOfFlashCard > 0)
{
   // Allocate memory for lpwfdFlashCard.
   lpwfdFlashCard = (WIN32_FIND_DATA *) LocalAlloc
                    (LPTR, iNumOfFlashCard * sizeof (WIN32_FIND_DATA));
   // Test for failed memory allocation.
   if (lpwfdFlashCard == NULL)
   {
   // Free the temp card memory.
      LocalFree (lpwfdFlashCardTmp);
      return;
   }
   // Assign lpwfdFlashCardTmp to lpwfdFlashCard.
   for (index=0; index < iNumOfFlashCard; ++index)
   {
    lpwfdFlashCard [index] = lpwfdFlashCardTmp [index];
    vMsg   = WideToAnsi(lpwfdFlashCard[index].cFileName);
    sdCard = hb_itemPutC(NULL, vMsg ) ;
    hb_itemArrayPut( sdCards, index+1, sdCard );
    hb_xfree( (void *) vMsg);

   }
// Free the memory.
   LocalFree (lpwfdFlashCard);
}
LocalFree (lpwfdFlashCardTmp);

hb_itemReturn(sdCards);
hb_itemRelease(sdCards);
hb_itemRelease(sdCard);
}


#pragma ENDDUMP



Saludos,
José Luis Capel
User avatar
jlcapel
 
Posts: 229
Joined: Wed Oct 12, 2005 5:32 pm
Location: Valencia - España

Postby jlcapel » Thu Jan 11, 2007 7:56 am

Hola,

Se me olvidó decir que hay que añadir la librería del vce note_prj.lib al proyecto.

Saludos,
José Luis Capel
User avatar
jlcapel
 
Posts: 229
Joined: Wed Oct 12, 2005 5:32 pm
Location: Valencia - España

Postby Antonio Linares » Thu Jan 11, 2007 11:29 am

José Luis,

gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 22 guests