VB.NET•Declare the Functions in the DLL

Listing 2. This code declares the functions used for Platform Invoke. You can find these functions in the coredll.dll file, which is part of the Windows CE operating system.

<DllImport("coredll.dll")> _
   Private Shared Function CreateFile(ByVal _
   lpFileName As String, ByVal dwDesiredAccess _
   As Integer, ByVal dwShareMode As Integer, _
   ByVal lpSecurityAttributes As Integer, _
   ByVal dwCreationDisposition As Integer, _
   ByVal dwFlagsAndAttributes As Integer, _
   ByVal hTemplateFile As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
   Private Shared Function ReadFile(ByVal hFile _
   As Integer, ByVal Buffer() As Byte, _
   ByVal nNumberOfBytesToRead As Integer, _
   ByRef lpNumberOfBytesRead As Integer, _
   ByRef lpOverlapped As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
   Private Shared Function WriteFile(ByVal _
   hFile As Integer, ByVal Buffer() As Byte, _
   ByVal nNumberOfBytesToWrite As Integer, _
   ByRef lpNumberOfBytesWritten As Integer, 
   ByVal lpOverlapped As Integer) As Boolean
End Function