[VB.NET] Problème pour Marshaliser une API
Bonjour tlm,
je n'arrive pas à trouver la bonne formulation pour utiliser la fonction CeReadFile.
MSDN dit : http://msdn.microsoft.com/library/de...adfilerapi.asp
Dans mon code je la déclare :
Code:
1 2 3 4
| Private Declare Function CeCreateFile Lib "rapi.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDistribution As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As IntPtr
Private Declare Function CeReadFile Lib "rapi.dll" (ByVal hFile As IntPtr, <MarshalAs(UnmanagedType.LPArray)> ByVal lpBuffer() As Byte,
ByVal nNumberOfBytesToRead As Integer, ByRef lpNumberOfBytesRead As Integer, ByRef lpOverlapped As Integer) As Boolean |
et plus loin dans code j'ai :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
Dim bLecture As Boolean = False
Dim nbCharLu As Integer
dim myBufferEntree(1) As Byte '
dim iNbCharALire As Integer = 1
Dim hdlFichier As IntPtr
hdlFichier = CeCreateFile(chemFichierSource, GENERIC_READ Or GENERIC_WRITE, 0, Nothing,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0)
If hdlFichier.ToInt32 <> INVALID_HANDLE_VALUE Then
bLecture = CeReadFile(hdlFichier, myBufferEntree, iNbCharALire, nbCharLu, 0)
If not bLecture Then
Affiche(CeGetLastError.ToString)
end if
end if |
CeGetLastError retourne toujours l'erreur 87 : paramétre incorecte!
Quelqu'un peut m'aider svp.
Lamalice.