pureRAPI est problème UNICODE...

Programmation d'applications complexes
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

pureRAPI est problème UNICODE...

Message par GallyHC »

Bonjour,

Voila je suis revenu sur une de met routine (pureRAPI), le problème est que si je compile le code en UNICODE pas de problème et sinon plantage (Compilateur). Voila le code au complet ou cas ou quelqu'un aurais une idee.

Code : Tout sélectionner

; +======================================================+
; |   GESTION DE RAPI.DLL (Réalisation par KoakDesign)   |
; +------------------------------------------------------+
; | COPYRIGHT(C)2007-2008, ALL RIGHT RESERVED KOAKDESIGN |
; +--------------+---------------------------------------+
; | Program type | PUREBASIC 4.40 (MODULE)               |
; +--------------+---------------------------------------+
; | VER & REV    | 3.0.0 RC0                             |
; +--------------+---------------------------------------+
; | Program name | ops_windows_activesync.pbi            |
; +======================================================+

; +======================================================+
; | Original Version: 3.0.0 RC0                          |
; +--------------+---------------------------------------+
; | Created by   | GallyHomeCorp                         |
; | Graphix by   |                                       |
; +--------------+---------------------------------------+
; | Comments:    |                                       |
; +--------------+                                       |
; |                                                      |
; |                                                      |
; |                                                      |
; +======================================================+

; +======================================================+
; | Système d'Exploitation                               |
; +--------------+---------------------------------------+
; | Window       | Oui                                   |
; | Linux        | Non                                   |
; | MacOS        | Non                                   |
; +======================================================+

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

EnableExplicit

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+
;- DECLARATION DES PROCEDURES.

Declare.b RAPIConnect()
Declare.b RAPIClose()
Declare.s RAPIGetCEOSVersionString()
Declare.b RAPIIsConnected()
Declare.i RAPIGDesktopDeviceCaps(lindex.l)
Declare.s RAPIErrorInformation()
Declare.s RAPIFindStorage()
Declare.b RAPIGetListFiles(filereps.s, sortname.b=#False)
Declare.l RAPIGetFileCount()
Declare.b RAPIGetFileInfo(lindex.l, *FileInfo)
Declare.l RAPIOpenFile(filename.s, mode.i, createnew.b, flags.l)
Declare.b RAPICopyCEFileToPC(CESourceFile.s, PCDestFile.s)
Declare.b RAPICopyPCFileToCE(PCSourceFile.s, CEDestFile.s)
Declare.b RAPIFileExists(CESourceFile.s)
Declare.b RAPICreateDirectory(filename.s)
Declare.b RAPIDeleteFile(filename.s)
Declare.b RAPIRenameFile(filename.s,newname.s)
Declare.b RAPIExecOnDevice(fileexec.s, command.s)
Declare.l RAPIMemorySpace(lindex.l)
Declare.l RAPIStorageSpace(lindex.l)
Declare.i RAPIPowerStatus()

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+
;- DECLARATION DES STRUCTURES.

;{ - STRUCTURE
Structure RAPIINIT
  cbSize.l
  heRapiInit.l
  hrRapiInit.l
EndStructure
Structure CEOSVERSIONINFO
  dwOSVersionInfoSize.l
  dwMajorVersion.l
  dwMinorVersion.l
  dwBuildNumber.l
  dwPlatformId.l
  szCSDVersion.s{128}
EndStructure
Structure CE_FIND_DATA
  dwFileAttributes.l
  ftCreationTime.FILETIME
  ftLastAccessTime.FILETIME
  ftLastWriteTime.FILETIME
  nFileSizeHigh.l
  nFileSizeLow.l
  dwOID.l
  cFileName.s{256}
EndStructure
Structure STORE_INFORMATION
  dwStoreSize.l
  dwFreeSize.l
EndStructure
Structure SYSTEM_POWER_STATUS_EX
  ACLineStatus.b
  BatteryFlag.b
  BatteryLifePercent.b
  Reserved1.b
  BatteryLifeTime.d
  BatteryFullLifeTime.d
  Reserved2.b
  BackupBatteryFlag.b
  BackupBatteryLifePercent.b
  Reserved3.b
  BackupBatteryLifeTime.d
  BackupBatteryFullLifeTime.d
EndStructure
Structure SYSTEM_COPY_FILE
    value.i
EndStructure
;}
;{ - GLOBAL
Global PureRAPI_GetFileCount.l
Global Dim PureRAPI_GetFileList.CE_FIND_DATA(0)
;}

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+
;- DECLARATION DES VARIABLES.

;{ - ALL CERAPI API.
#OPENLIB_0                  = 1
#INVALID_HANDLE_VALUE       = -1
#TIME_WAIT_READ             = $1
#ONE_SECOND                 = $3E8
#GENERIC_READ               = $80000000
#GENERIC_WRITE              = $40000000
#CREATE_NEW                 = $1
#OPEN_EXISTING              = $3
;}
;{ - ALL CERAPI API.
#ERROR_SUCCESS              = $0
#ERROR_FILE_NOT_FOUND       = $2
#ERROR_PATH_NOT_FOUND       = $3
#ERROR_ACCESS_DENIED        = $5
#ERROR_INVALID_HANDLE       = $6
#ERROR_WRITE_PROTECT        = $13
#ERROR_FILE_EXISTS          = $50
#ERROR_INVALID_PARAMETER    = $57
#ERROR_DISK_FULL            = $70
#ERROR_INVALID_NAME         = $7B
;}
;{ - CeCreateFile.
#FILE_ATTRIBUTE_READONLY    = $1
#FILE_ATTRIBUTE_HIDDEN      = $2
#FILE_ATTRIBUTE_SYSTEM      = $4
#FILE_ATTRIBUTE_DIRECTORY   = $10
#FILE_ATTRIBUTE_SPECIAL     = $14
#FILE_ATTRIBUTE_ARCHIVE     = $20
#FILE_ATTRIBUTE_NORMAL      = $80
#FILE_ATTRIBUTE_TEMPORARY   = $100
#FILE_ATTRIBUTE_STORAGE     = $110
#FILE_ATTRIBUTE_COMPRESSED  = $800
;}
;{ - CeGetDesktopDeviceCaps.
#DRIVERVERSION              = $0
#TECHNOLOGY                 = $2
#HORZSIZE                   = $4
#VERTSIZE                   = $6
#HORZRES                    = $8
#VERTRES                    = $A
#BITSPIXEL                  = $C
#PLANES                     = $E
#NUMBRUSHES                 = $10
#NUMPENS                    = $12
#NUMMARKERS                 = $14
#NUMFONTS                   = $16
#NUMCOLORS                  = $18
#PDEVICESIZE                = $1A
#CURVECAPS                  = $1C
#LINECAPS                   = $1E
#POLYGONALCAPS              = $20
#TEXTCAPS                   = $22
#CLIPCAPS                   = $24
#RASTERCAPS                 = $26
#ASPECTX                    = $28
#ASPECTY                    = $2A
#ASPECTXY                   = $2C
#PHYSICALWIDTH              = $6E
#PHYSICALHEIGHT             = $6F
#PHYSICALOFFSETX            = $70
#PHYSICALOFFSETY            = $71
#SHADEBLENDCAPS             = $78
;}

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.b RAPIConnect()
; INITIALISATION DE LA CONNEXION (RAPI.DLL).
  If OpenLibrary(#OPENLIB_0, "rapi.dll")
    Define Hr.l
    Define dwTimeout.l
    Define dwWaitRet.l
    Define pRapiInit.RAPIINIT

    dwTimeout = #TIME_WAIT_READ * #ONE_SECOND
    pRapiInit\cbSize = SizeOf(pRapiInit)
    pRapiInit\heRapiInit = 0
    pRapiInit\hrRapiInit = 0
    Hr = CallFunction(#OPENLIB_0, "CeRapiInitEx", @pRapiInit)
    If Hr <> #INVALID_HANDLE_VALUE
      dwWaitRet = WaitForSingleObject_(pRapiInit\heRapiInit, dwTimeout)
      If dwWaitRet = 0
        If pRapiInit\hrRapiInit >= 0
          ProcedureReturn #True
        Else
          Goto RAPIClose
        EndIf
      Else
        Goto RAPIClose
      EndIf
    Else
      Goto RAPIClose
    EndIf
  Else
    RAPIErrorInformation()
    ProcedureReturn #False
  EndIf
RAPIClose:
  If Hr >= 0
    RAPIErrorInformation()
    CallFunction(#OPENLIB_0, "CeRapiUninit")
    CloseLibrary(#OPENLIB_0)
  EndIf
  ProcedureReturn #False
 
EndProcedure

Procedure.b RAPIClose()
; FERMETURE DE LA CONNEXION (RAPI.DLL).
  CallFunction(#OPENLIB_0, "CeRapiUninit")
  CloseLibrary(#OPENLIB_0)

EndProcedure

Procedure.s RAPIGetCEOSVersionString() 
; DONNE LA VERSION DU POCKET-PC.
  Define ceosver.CEOSVERSIONINFO

  ceosver\dwOSVersionInfoSize = SizeOf(ceosver)
  If CallFunction(#OPENLIB_0, "CeGetVersionEx", @ceosver)
    ProcedureReturn Str(ceosver\dwMajorVersion) + "." + Str(ceosver\dwMinorVersion) + "." + Str(ceosver\dwBuildNumber) + " " + ceosver\szCSDVersion
  EndIf

EndProcedure

Procedure.b RAPIIsConnected()
; VERIFICATION DE LA CONNEXION.
  If RapiGetCEOSVersionString() <> ""
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.i RAPIGDesktopDeviceCaps(lindex.l)
; ROUTINE DE RECUPERATION DES INFORMATIONS. 
  ProcedureReturn CallFunction(#OPENLIB_0, "CeGetDesktopDeviceCaps", lindex)

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.s RAPIErrorInformation()
; ROUTINE DE GESTION DES ERREURS.
  Define lceerror.l
  Define sceerror.s

  lceerror = CallFunction(#OPENLIB_0, "CeGetLastError")
  Select lceerror
    Case #ERROR_FILE_NOT_FOUND:     sceerror = "Erreur: Ce fichier n'existe pas..."
    Case #ERROR_PATH_NOT_FOUND:     sceerror = "Erreur: Ce répertoire n'existe pas..."
    Case #ERROR_INVALID_HANDLE:     sceerror = "Erreur: Aucun handle valide..."
    Case #ERROR_ACCESS_DENIED:      sceerror = "Erreur: Accès interdit..."
    Case #ERROR_WRITE_PROTECT:      sceerror = "Erreur: La mémoire est protégée en écriture."
    Case #ERROR_FILE_EXISTS:        sceerror = "Erreur: Le fichier est présent sur le périphérique."
    Case #ERROR_INVALID_PARAMETER:  sceerror = "Erreur: Les paramètres sont invalides..."
    Case #ERROR_DISK_FULL:          sceerror = "Erreur: Le disque est plein..."
    Case #ERROR_INVALID_NAME:       sceerror = "Erreur: Le nom est invalide..."
  EndSelect
  If sCeError <> ""
    MessageRequester("RAPI.DLL Error Report:", sceerror, #PB_MessageRequester_Ok)
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.s RAPIFindStorage()
; ROUTINE DE RECHERCHE D'UNE CARTE SD.
  Define searchhandle.l
  Define findreturn.l
  Define result.s
  Define storage.s
  Define filereps.s
  Protected finddata.CE_FIND_DATA

  filereps = "\*"
  searchhandle = CallFunction(#OPENLIB_0, "CeFindFirstFile", @filereps, finddata)
  If searchhandle <> #INVALID_HANDLE_VALUE
    Repeat
      result = finddata\cFileName
      If finddata\dwFileAttributes = #FILE_ATTRIBUTE_STORAGE And LCase(result) <> "storage" And LCase(result) <> "bluetooth"
        storage = "\" + result + "\"
        Goto RAPIEnd
      EndIf
      findreturn = CallFunction(#OPENLIB_0, "CeFindNextFile", searchhandle, finddata)
    Until findreturn = 0
  EndIf
  RAPIEnd:
  ProcedureReturn storage

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.b RAPIGetListFiles(filereps.s, sortname.b=#False)
; ROUTINE DE LISTAGE D'UN REPERTOIRE.
  Define i.l
  Define searchhandle.l
  Define findreturn.l
  Define result.s
  Protected finddata.CE_FIND_DATA

  If Right(filereps,1) <> "*"
    filereps = filereps + "*"
  EndIf
  searchhandle = CallFunction(#OPENLIB_0, "CeFindFirstFile", @filereps, finddata)
  If searchhandle <> #INVALID_HANDLE_VALUE
    PureRAPI_GetFileCount = 0
    ReDim PureRAPI_GetFileList(0)
    Repeat
      ReDim PureRAPI_GetFileList(i)
      PureRAPI_GetFileList(i)\cFileName                       = finddata\cFileName
      PureRAPI_GetFileList(i)\dwFileAttributes                = finddata\dwFileAttributes
      PureRAPI_GetFileList(i)\ftCreationTime\dwLowDateTime    = finddata\ftCreationTime\dwLowDateTime
      PureRAPI_GetFileList(i)\ftCreationTime\dwHighDateTime   = finddata\ftCreationTime\dwHighDateTime
      PureRAPI_GetFileList(i)\ftLastAccessTime\dwLowDateTime  = finddata\ftLastAccessTime\dwLowDateTime
      PureRAPI_GetFileList(i)\ftLastAccessTime\dwHighDateTime = finddata\ftLastAccessTime\dwHighDateTime
      PureRAPI_GetFileList(i)\ftLastWriteTime\dwLowDateTime   = finddata\ftLastWriteTime\dwLowDateTime
      PureRAPI_GetFileList(i)\ftLastWriteTime\dwHighDateTime  = finddata\ftLastWriteTime\dwHighDateTime
      PureRAPI_GetFileList(i)\nFileSizeHigh                   = finddata\nFileSizeHigh
      PureRAPI_GetFileList(i)\nFileSizeLow                    = finddata\nFileSizeLow
      PureRAPI_GetFileList(i)\dwOID                           = finddata\dwOID
      findreturn = CallFunction(#OPENLIB_0, "CeFindNextFile", searchhandle, finddata)
      i+1
    Until findreturn = #ERROR_SUCCESS
    If sortname = #True
      SortStructuredArray(PureRAPI_GetFileList(), #PB_Sort_Ascending | #PB_Sort_NoCase, SizeOf(CE_FIND_DATA\cFileName), #PB_Sort_String)
    EndIf
    PureRAPI_GetFileCount = i - 1
    ProcedureReturn #True
  EndIf
  PureRAPI_GetFileCount = 0
  ProcedureReturn #False

EndProcedure

Procedure.l RAPIGetFileCount()
; DONNE LE NOMBRE DE FICHIER.
  ProcedureReturn PureRAPI_GetFileCount

EndProcedure

Procedure.b RAPIGetFileInfo(lindex.l, *FileInfo)
; ENVOIS LES INFORMATIONS DU FICHIER.
  If lindex => 0 And lindex <= PureRAPI_GetFileCount
    CopyMemory(@PureRAPI_GetFileList(lindex), *FileInfo, SizeOf(CE_FIND_DATA))
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.l RAPIOpenFile(filename.s, mode.i, createnew.b, flags.l)
; ROUTINE D'OUVERTURE D'UN FICHIER.
  Define lfilemode.l
  Define createdist.l
  Protected security.SECURITY_ATTRIBUTES

  Select mode
    Case 1: lfilemode = #GENERIC_READ
    Case 2: lfilemode = #GENERIC_WRITE
    Case 3: lfilemode = #GENERIC_READ Or #GENERIC_WRITE
  EndSelect
  If createnew = #True
    createdist = #CREATE_NEW
  Else
    createdist = #OPEN_EXISTING
  EndIf
  ProcedureReturn CallFunction(#OPENLIB_0, "CeCreateFile", @filename, lfilemode, 0, security, createdist, flags, 0)

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.b RAPICopyCEFileToPC(CESourceFile.s, PCDestFile.s)
; ROUTINE DE COPIE DU FICHIER POCKET->PC.
  Define i.i
  Define lresult.l
  Define sresult.s
  Define lbufferlen.l = 2048
  Define lbytesread.l
  Define lcefilehandle.l
  Dim bfile.b(lbufferlen)

  lcefilehandle = RAPIOpenFile(CESourceFile, 1, #False, #FILE_ATTRIBUTE_NORMAL)
  If lcefilehandle <> #INVALID_HANDLE_VALUE
    If CreateFile(0, PCDestFile)
      Repeat
        lresult = CallFunction(#OPENLIB_0, "CeReadFile", lcefilehandle, @bfile(0), lbufferlen, @lbytesread, 0)
        If lresult And lbytesread > 0
          sresult = ""
          For i=0 To lbytesread - 1
            WriteByte(0, bfile(i))
          Next i
        EndIf
      Until lresult And lbytesread = 0
      CloseFile(0)
    EndIf
    If RAPIErrorInformation() <> ""
    EndIf
    lResult = CallFunction(#OPENLIB_0, "CeCloseHandle", lCeFileHandle)
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf

EndProcedure

Procedure.b RAPICopyPCFileToCE(PCSourceFile.s, CEDestFile.s)
; ROUTINE DE COPIE DU FICHIER PC->POCKET.
  Define i.l
  Define lfllen.l
  Define lresult.l
  Define lbitpos.l
  Define lbufferlen.l = 2048
  Define bendcopy.b  = #False
  Define lbyteswrite.l
  Define ltotalcopied.l
  Define lcefilehandle.l
  Dim bfile.SYSTEM_COPY_FILE(0)

  If ReadFile(0, PCSourceFile)
    lfllen = Lof(0)
    ReDim bfile(lfllen)
    ReadData(0,@bfile(),lfllen)
    CloseFile(0)
    If RAPIFileExists(CEDestFile)
      If RAPIDeleteFile(CEDestFile) = #False
        ProcedureReturn #False
      EndIf
    EndIf
    lcefilehandle = RAPIOpenFile(CEDestFile, 2, #True, #FILE_ATTRIBUTE_NORMAL)
    If lcefilehandle <> #INVALID_HANDLE_VALUE
      lbitpos = 0
      Repeat
        If lfllen - ltotalcopied > lbufferlen
          lresult = CallFunction(#OPENLIB_0, "CeWriteFile", lcefilehandle, @bfile(lbitpos), lbufferlen, @lbyteswrite, 0)
          ltotalcopied + lbyteswrite
          lbitpos + (lbufferlen/4)
        Else
          lbufferlen = lfllen - ltotalcopied
          If lbufferlen > 0
            lresult = CallFunction(#OPENLIB_0, "CeWriteFile", lcefilehandle, @bfile(lbitpos), lbufferlen, @lbyteswrite, 0)
          EndIf
          ltotalcopied + lbyteswrite
          bendcopy = #True
        EndIf
      Until bendcopy = #True
      lresult = CallFunction(#OPENLIB_0, "CeCloseHandle", lCeFileHandle)
      Debug RAPIErrorInformation()
    EndIf
  Else
    ProcedureReturn #False
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.b RAPIFileExists(CESourceFile.s)
; ROUTINE DE VERIFICATION "FileExists".
  Define lresult.l
  Define lcefilehandle.l

  lcefilehandle = RAPIOpenFile(CESourceFile, 1, #False, #FILE_ATTRIBUTE_NORMAL)
  If lcefilehandle <> #INVALID_HANDLE_VALUE
    lresult = CallFunction(#OPENLIB_0, "CeCloseHandle", lcefilehandle)
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf

EndProcedure

Procedure.b RAPICreateDirectory(filename.s)
; ROUTINE DE SUPPRESSION D'UN FICHIER. 
  ProcedureReturn CallFunction(#OPENLIB_0, "CeCreateDirectory", @filename, 0)

EndProcedure

Procedure.b RAPIDeleteFile(filename.s)
; ROUTINE DE SUPPRESSION D'UN FICHIER.
  If RAPIFileExists(filename)
    ProcedureReturn CallFunction(#OPENLIB_0, "CeDeleteFile", @filename)
  Else
    ProcedureReturn #False
  EndIf

EndProcedure

Procedure.b RAPIRenameFile(filename.s,newname.s)
; ROUTINE DE RENOMMAGE D'UN FICHIER.
  If RAPIFileExists(newname)
    RAPIDeleteFile(newname)
  EndIf
  If CallFunction(#OPENLIB_0, "CeMoveFile", @filename, @newname)
    RAPIErrorInformation()
    ProcedureReturn #False
  Else
    ProcedureReturn #True
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.b RAPIExecOnDevice(fileexec.s, command.s)
; ROUTINE D'EXECUTION D'UN PROGRAMME.
  Protected newprocinfo.PROCESS_INFORMATION

  If CallFunction(#OPENLIB_0, "CeCreateProcess", @fileexec, @command, 0, 0, 0, 0, 0, 0, 0, newProcInfo) = 0
    ProcedureReturn #False
  Else
    ProcedureReturn #True
  EndIf

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.l RAPIMemorySpace(lindex.l)
; ROUTINE DE VERIFICATION DE LA MEMOIRE.
  Define lresult.l

  Protected sMemoryMem.MEMORYSTATUS  
  lresult = CallFunction(#OPENLIB_0, "CeGlobalMemoryStatus",sMemoryMem)
  Select lindex
    Case 0:       ProcedureReturn sMemoryMem\dwTotalPhys
    Case 1:       ProcedureReturn sMemoryMem\dwTotalPhys - sMemoryMem\dwAvailPhys
  EndSelect
  ProcedureReturn 0

EndProcedure

Procedure.l RAPIStorageSpace(lindex.l)
; ROUTINE DE VERIFICATION DU STORAGE.
  Define lresult.l
  Protected sMemoryStr.STORE_INFORMATION

  lresult = CallFunction(#OPENLIB_0, "CeGetStoreInformation",sMemoryStr)
  Select lindex
    Case 0:       ProcedureReturn sMemoryStr\dwStoreSize
    Case 1:       ProcedureReturn sMemoryStr\dwFreeSize
  EndSelect
  ProcedureReturn 0

EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

Procedure.i RAPIPowerStatus()
; ROUTINE DE VERIFICATION DES BATTERIES.
  Protected pStatus.SYSTEM_POWER_STATUS_EX

  CallFunction(#OPENLIB_0, "CeGetSystemPowerStatusEx", @pStatus, #True)
  ProcedureReturn pStatus\BatteryLifePercent
  
EndProcedure

; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************

; +--------------------------------------------------------------------------+
; |                                                                          |
; +--------------------------------------------------------------------------+

; EXEMPLE POUR LISTE LES FICHIERS DE LA RACINE (LA RACINE EST "\").
Define i.l
Define FileInfo.CE_FIND_DATA
If RAPIConnect()
  If RAPIIsConnected()
    Debug "Résolution Ecran : " + Str(RAPIGDesktopDeviceCaps(#HORZRES)) + "x" + Str(RAPIGDesktopDeviceCaps(#VERTRES)) + "x" + Str(RAPIGDesktopDeviceCaps(#BITSPIXEL))
    Debug "Répertoire Memoire : " + RAPIFindStorage()
    Debug "Charge Batterie : " + Str(RAPIPowerStatus()) + "%"
    RAPIGetListFiles("\", #True)
    For i=0 To RAPIGetFileCount()
      RAPIGetFileInfo(i, @FileInfo.CE_FIND_DATA)
      If FileInfo\dwFileAttributes = #FILE_ATTRIBUTE_DIRECTORY Or FileInfo\dwFileAttributes = #FILE_ATTRIBUTE_STORAGE Or FileInfo\dwFileAttributes = #FILE_ATTRIBUTE_SPECIAL
        Debug "Dir: " + FileInfo\cFileName
      EndIf
    Next i
    For i=0 To RAPIGetFileCount()
      RAPIGetFileInfo(i, @FileInfo.CE_FIND_DATA)
      If FileInfo\dwFileAttributes <> #FILE_ATTRIBUTE_DIRECTORY And FileInfo\dwFileAttributes <> #FILE_ATTRIBUTE_STORAGE And FileInfo\dwFileAttributes <> #FILE_ATTRIBUTE_SPECIAL
        Debug FileInfo\cFileName
      EndIf
    Next i
  EndIf
  RAPIClose()
EndIf
j'espere que quelqu'un pourras le dire le pourquoi, mais il faut un pocket-pc pour faire le test.

Merci d'avance,
GallyHC
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: pureRAPI est problème UNICODE...

Message par Le Soldat Inconnu »

parfois il faut se méfier de certaine structure qui change entre unicode et ascii, il faut bien zieuter msdn. j'ai pas de CE alors pour tester
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
GallyHC
Messages : 1708
Inscription : lun. 17/déc./2007 12:44

Re: pureRAPI est problème UNICODE...

Message par GallyHC »

Bonjour,

Deja le problème commence a cette Procedure (If CallFunction(#OPENLIB_0, "CeGetVersionEx", @ceosver)) sa plante. Visiblement l'unicode peu etre utile (mais pas sur), mais comment faire pour passe ce problème car en VB6 avec un code identique aucun problème et je ne penses pas VB6 gere l'unicode en direct.

Code : Tout sélectionner

Procedure.s RAPIGetCEOSVersionString() 
; DONNE LA VERSION DU POCKET-PC.
  Define ceosver.CEOSVERSIONINFO

  ceosver\dwOSVersionInfoSize = SizeOf(ceosver)
  If CallFunction(#OPENLIB_0, "CeGetVersionEx", @ceosver)
    ProcedureReturn Str(ceosver\dwMajorVersion) + "." + Str(ceosver\dwMinorVersion) + "." + Str(ceosver\dwBuildNumber) + " " + ceosver\szCSDVersion
  EndIf

EndProcedure
recherche sur le net http://msdn.microsoft.com/en-us/library/ms913907.aspx lien vers MSDN microsoft.

Cordialement,
GallyHC
Configuration : Tower: Windows 10 (Processeur: i7 "x64") (Mémoire: 16Go) (GeForce GTX 760 - 2Go) - PureBasic 5.72 (x86 et x64)
Répondre