Moi aussi je voulais faire une librairie pour tous mais sa compile mais des que je l'utilise sa plante ou detecte pas. Par contre le code fonctionne en tant que tel.
J'espere que quelqu'un pourras m'aide comme cela je partagerais avec tous et surtout les evolutions futur

Code : Tout sélectionner
; +======================================================+
; | GESTION DE RAPI.DLL (Réalisation par KoakDesign) |
; +------------------------------------------------------+
; | COPYRIGHT(C)2007-2008, ALL RIGHT RESERVED KOAKDESIGN |
; +--------------+---------------------------------------+
; | VER & REV | 0.0.1 |
; +--------------+---------------------------------------+
; | Program type | PUREBASIC 4.40 (DLL) |
; +--------------+---------------------------------------+
; | Program name | PureRAPI.pb |
; +======================================================+
; +======================================================+
; | Original Version: 0.0.1 |
; +--------------+---------------------------------------+
; | Created by | Gally Home Corp |
; | Graphix by | |
; +--------------+---------------------------------------+
; | Comments: | |
; +--------------+ |
; | |
; | |
; | |
; +======================================================+
; +======================================================+
; | Système d'Exploitation |
; +--------------+---------------------------------------+
; | Window | Oui |
; | Linux | Non |
; | MacOS | Non |
; +======================================================+
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- DECLARATION DES PROCEDURES.
Declare PureRAPI_About()
Declare.s PureRAPI_Version()
Declare.s PureRAPI_Information()
Declare.s PureRAPI_DateConvert(dtLow.l, dtHigh.l, mode.l)
Declare.l PureRAPI_OpenFile(filename.s, mode.i, createnew.b, flags.l)
Declare.b PureRAPI_Connect()
Declare.b PureRAPI_Close()
Declare.s PureRAPI_GetCEOSVersionString()
Declare.b PureRAPI_IsConnected()
Declare.i PureRAPI_GetDesktopDeviceCaps(lindex.l)
Declare.b PureRAPI_ErrorInformation()
Declare.s PureRAPI_FindStorage()
Declare.b PureRAPI_GetListFiles(directory.s)
Declare.b PureRAPI_GetFileCount()
Declare.b PureRAPI_GetFileInfo(lindex.l, *FileInfo)
Declare.b PureRAPI_CopyCEFileToPC(CESourceFile.s, PCDestFile.s)
Declare.b PureRAPI_CopyPCFileToCE(PCSourceFile.s, CEDestFile.s)
Declare.b PureRAPI_FileExists(CESourceFile.s)
Declare.b PureRAPI_CreateDirectory(filename.s)
Declare.b PureRAPI_DeleteFile(filename.s)
Declare.b PureRAPI_DeleteDirectory(directory.s)
Declare.b PureRAPI_RenameFile(filename.s, newname.s)
Declare.b PureRAPI_ExecOnDevice(fileexec.s, command.s)
Declare.l PureRAPI_MemorySpace(lindex.l)
Declare.l PureRAPI_StorageSpace(lindex.l)
Declare.i PureRAPI_PowerStatus()
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- DECLARATION DES STRUCTURES.
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
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;- DECLARATION DES VARIABLES.
;{
Global OPENLIB_RAPI.l
Global PureRAPI_GetFileCount.l
Global Dim PureRAPI_GetFileList.CE_FIND_DATA(0)
;}
;{
#Version = "0.0.1"
#Comment = "PureRAPI Dll by GallyHC of www.koakdesign.info"
;}
;{ - ALL CERAPI API
#INVALID_HANDLE_VALUE = -1
#TIME_WAIT_READ = $5
#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_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
;}
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL PureRAPI_Init()
;
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL PureRAPI_About()
; DONNE LA VERSION DE PURERAPI.
MessageRequester("PureRAPI Information :", #Comment + Chr(10) + Chr(10) +"DLL Verion: " + #Version, #PB_MessageRequester_Ok)
EndProcedure
ProcedureDLL.s PureRAPI_Version()
; DONNE LA VERSION DE PURERAPI.
ProcedureReturn #Version
EndProcedure
ProcedureDLL.s PureRAPI_Information()
; DONNE LA VERSION DE PURERAPI.
ProcedureReturn #Comment
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.s PureRAPI_DateConvert(dtLow.l, dtHigh.l, mode.l)
; ROUTINE DE CONVERTION DE LA DATE.
Define lresult.l
Define sresult.s
Define fTime.FILETIME
Define sTime.SYSTEMTIME
fTime\dwLowDateTime = dtLow
fTime\dwHighDateTime = dtHigh
FileTimeToSystemTime_(fTime, @sTime)
lresult = Date(sTime\wYear, sTime\wMonth, sTime\wDay, sTime\wHour, sTime\wMinute, sTime\wSecond)
Select mode
Case 1: sresult = FormatDate("%yyyy.%mm.%dd", lresult)
Case 2: sresult = FormatDate("%dd/%mm/%yyyy", lresult)
Default: sresult = FormatDate("%yyyy.%mm.%dd", lresult)
EndSelect
ProcedureReturn sresult
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.l PureRAPI_OpenFile(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_RAPI, "CeCreateFile", @filename, lfilemode, 0, security, createdist, flags, 0)
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_Connect()
; INITIALISATION DE LA CONNEXION (RAPI.DLL).
OPENLIB_RAPI = OpenLibrary(#PB_Any, "rapi.dll")
If OPENLIB_RAPI <> 0
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_RAPI, "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
ProcedureReturn #False
EndIf
RAPIClose:
If Hr >= 0
CallFunction(OPENLIB_RAPI, "CeRapiUninit")
CloseLibrary(OPENLIB_RAPI)
EndIf
ProcedureReturn #False
EndProcedure
ProcedureDLL.b PureRAPI_Close()
; FERMETURE DE LA CONNEXION (RAPI.DLL).
If OPENLIB_RAPI <> 0
CallFunction(OPENLIB_RAPI, "CeRapiUninit")
CloseLibrary(OPENLIB_RAPI)
OPENLIB_RAPI = 0
EndIf
EndProcedure
ProcedureDLL.s PureRAPI_GetCEOSVersionString()
; DONNE LA VERSION DU POCKET-PC.
Define ceosver.CEOSVERSIONINFO
If OPENLIB_RAPI <> 0
ceosver\dwOSVersionInfoSize = SizeOf(ceosver)
CallFunction(OPENLIB_RAPI, "CeGetVersionEx", @ceosver)
ProcedureReturn Str(ceosver\dwMajorVersion) + "." + Str(ceosver\dwMinorVersion) + "." + Str(ceosver\dwBuildNumber) + " " + ceosver\szCSDVersion
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_IsConnected()
; VERIFICATION DE LA CONNEXION.
If PureRAPI_GetCEOSVersionString() <> ""
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.i PureRAPI_GetDesktopDeviceCaps(lindex.l)
; ROUTINE DE SUPPRESSION D'UN FICHIER.
If OPENLIB_RAPI <> 0
ProcedureReturn CallFunction(OPENLIB_RAPI, "CeGetDesktopDeviceCaps", lindex)
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_ErrorInformation()
; ROUTINE DE GESTION DES ERREURS.
Define lceerror.l
Define sceerror.s
If OPENLIB_RAPI <> 0
lceerror = CallFunction(OPENLIB_RAPI, "CeGetLastError")
Select lceerror
Case #ERROR_FILE_NOT_FOUND: sceerror = "Erreur: Ce fichier n'existe pas..."
Case #ERROR_PATH_NOT_FOUND: sceerror = "Erreur: Ce Path n'existe pas..."
Case #ERROR_ACCESS_DENIED: sceerror = "Erreur: Acces Interdit..."
Case #ERROR_FILE_EXISTS: sceerror = "Erreur: Fichier présent sur le Pocket"
Case #ERROR_INVALID_PARAMETER: sceerror = "Erreur: Paramètre Invalide..."
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)
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #False
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.s PureRAPI_FindStorage()
; 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
If OPENLIB_RAPI <> 0
filereps = "\*"
searchhandle = CallFunction(OPENLIB_RAPI, "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_RAPI, "CeFindNextFile", searchhandle, finddata)
Until findreturn = 0
EndIf
RAPIEnd:
ProcedureReturn storage
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_GetListFiles(directory.s)
; ROUTINE DE LISTAGE D'UN REPERTOIRE.
Define i.l
Define searchhandle.l
Define findreturn.l
Protected finddata.CE_FIND_DATA
If OPENLIB_RAPI <> 0
If Right(directory,1) <> "*"
directory = directory + "*"
EndIf
searchhandle = CallFunction(OPENLIB_RAPI, "CeFindFirstFile", @directory, 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_RAPI, "CeFindNextFile", searchhandle, finddata)
i+1
Until findreturn = #ERROR_SUCCESS
EndIf
EndIf
PureRAPI_GetFileCount = i - 1
EndProcedure
ProcedureDLL.b PureRAPI_GetFileCount()
; DONNE LE NOMBRE DE FICHIER.
ProcedureReturn PureRAPI_GetFileCount
EndProcedure
ProcedureDLL.b PureRAPI_GetFileInfo(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
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_CopyCEFileToPC(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)
If OPENLIB_RAPI <> 0
lcefilehandle = PureRAPI_OpenFile(CESourceFile, 1, #False, #FILE_ATTRIBUTE_NORMAL)
If lcefilehandle <> #INVALID_HANDLE_VALUE
If CreateFile(0, PCDestFile)
Repeat
lresult = CallFunction(OPENLIB_RAPI, "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 PureRAPI_ErrorInformation() = #True
EndIf
lresult = CallFunction(OPENLIB_RAPI, "CeCloseHandle", lcefilehandle)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_CopyPCFileToCE(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 OPENLIB_RAPI <> 0
If ReadFile(0, PCSourceFile)
lfllen = Lof(0)
ReDim bfile(lfllen)
ReadData(0,@bfile(),lfllen)
CloseFile(0)
If PureRAPI_FileExists(CEDestFile)
If PureRAPI_DeleteFile(CEDestFile) = #False
ProcedureReturn #False
EndIf
EndIf
lcefilehandle = PureRAPI_OpenFile(CEDestFile, 2, #True, #FILE_ATTRIBUTE_NORMAL)
If lcefilehandle <> #INVALID_HANDLE_VALUE
lbitpos = 0
Repeat
If lfllen - ltotalcopied > lbufferlen
lresult = CallFunction(OPENLIB_RAPI, "CeWriteFile", lcefilehandle, @bfile(lbitpos), lbufferlen, @lbyteswrite, 0)
ltotalcopied + lbyteswrite
lbitpos + (lbufferlen/4)
Else
lbufferlen = lfllen - ltotalcopied
If lbufferlen > 0
lresult = CallFunction(OPENLIB_RAPI, "CeWriteFile", lcefilehandle, @bfile(lbitpos), lbufferlen, @lbyteswrite, 0)
EndIf
ltotalcopied + lbyteswrite
bendcopy = #True
EndIf
Until bendcopy = #True
lresult = CallFunction(OPENLIB_RAPI, "CeCloseHandle", lcefilehandle)
Debug PureRAPI_ErrorInformation()
EndIf
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_FileExists(CESourceFile.s)
; ROUTINE DE VERIFICATION "FileExists".
Define lresult.l
Define lcefilehandle.l
If OPENLIB_RAPI <> 0
lcefilehandle = PureRAPI_OpenFile(CESourceFile, 1, #False, #FILE_ATTRIBUTE_NORMAL)
If lcefilehandle <> #INVALID_HANDLE_VALUE
lresult = CallFunction(OPENLIB_RAPI, "CeCloseHandle", lcefilehandle)
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_CreateDirectory(filename.s)
; ROUTINE DE SUPPRESSION D'UN FICHIER.
If OPENLIB_RAPI <> 0
ProcedureReturn CallFunction(OPENLIB_RAPI, "CeCreateDirectory", filename, 0)
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_DeleteFile(filename.s)
; ROUTINE DE SUPPRESSION D'UN FICHIER.
If OPENLIB_RAPI <> 0
If PureRAPI_FileExists(filename)
ProcedureReturn CallFunction(OPENLIB_RAPI, "CeDeleteFile", @filename)
Else
ProcedureReturn #False
EndIf
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_DeleteDirectory(directory.s)
; ROUTINE DE SUPPRESSION D'UN FICHIER.
If OPENLIB_RAPI <> 0
ProcedureReturn CallFunction(OPENLIB_RAPI, "CeRemoveDirectory", @directory)
EndIf
EndProcedure
ProcedureDLL.b PureRAPI_RenameFile(filename.s, newname.s)
; ROUTINE DE RENOMMAGE D'UN FICHIER.
If OPENLIB_RAPI <> 0
If PureRAPI_FileExists(newname)
PureRAPI_DeleteFile(newname)
EndIf
If CallFunction(OPENLIB_RAPI, "CeMoveFile", @filename, @newname)
PureRAPI_ErrorInformation()
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.b PureRAPI_ExecOnDevice(fileexec.s, command.s)
; ROUTINE D'EXECUTION D'UN PROGRAMME.
Protected newprocinfo.PROCESS_INFORMATION
If OPENLIB_RAPI <> 0
If CallFunction(OPENLIB_RAPI, "CeCreateProcess", @fileexec, @command, 0, 0, 0, 0, 0, 0, 0, newprocinfo) = 0
ProcedureReturn #False
Else
ProcedureReturn #True
EndIf
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
ProcedureDLL.l PureRAPI_MemorySpace(lindex.l)
; ROUTINE DE VERIFICATION DE LA MEMOIRE.
Define lresult.l
Protected sMemoryMem.MEMORYSTATUS
If OPENLIB_RAPI <> 0
lresult = CallFunction(OPENLIB_RAPI, "CeGlobalMemoryStatus",sMemoryMem)
Select lindex
Case 0: ProcedureReturn sMemoryMem\dwTotalPhys
Case 1: ProcedureReturn sMemoryMem\dwTotalPhys - sMemoryMem\dwAvailPhys
EndSelect
ProcedureReturn 0
EndIf
EndProcedure
ProcedureDLL.l PureRAPI_StorageSpace(lindex.l)
; ROUTINE DE VERIFICATION DU STORAGE.
Define lresult.l
Protected sMemoryStr.STORE_INFORMATION
If OPENLIB_RAPI <> 0
lresult = CallFunction(OPENLIB_RAPI, "CeGetStoreInformation",sMemoryStr)
Select lindex
Case 0: ProcedureReturn sMemoryStr\dwStoreSize
Case 1: ProcedureReturn sMemoryStr\dwFreeSize
EndSelect
ProcedureReturn 0
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
ProcedureDLL.i PureRAPI_PowerStatus()
; ROUTINE DE VERIFICATION DES BATTERIES.
Protected pStatus.SYSTEM_POWER_STATUS_EX
If OPENLIB_RAPI <> 0
CallFunction(OPENLIB_RAPI, "CeGetSystemPowerStatusEx", @pStatus, #True)
ProcedureReturn pStatus\BatteryLifePercent
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Define i.l
Define FileInfo.CE_FIND_DATA
PureRAPI_About()
If PureRAPI_Connect()
If PureRAPI_IsConnected()
PureRAPI_GetListFiles("\")
For i=0 To PureRAPI_GetFileCount()
PureRAPI_GetFileInfo(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
Else
Debug FileInfo\cFileName
EndIf
Next i
EndIf
PureRAPI_Close()
EndIf
GallyHC