请问,wince6.0下的开发的流驱动,VB.net写的应用程序如何调用里面的dll文件中的函数?之前在C++中写的应用程序,使用CreateFile等函数。
下面附c++中写的应用程序对ADC操作的代码,已经能读取ARM本身A/D寄存器中的数据,但是现在想用VB.NET开发,想问问各位大牛,该如何在VB.NET中使用CreateFile,DeviceIoControl,ReadFile等函数?是先声明,是就能直接使用?
int channel =0;
m_hadc=CreateFile(_T("ADC1:"), GENERIC_READ | GENERIC_WRITE, 0, NULL,OPEN_EXISTING, 0, 0);
if (m_hadc == INVALID_HANDLE_VALUE)
{
MessageBox(_T("Open ADC Driver error!"));
}
DeviceIoControl(m_hadc,IO_ADC_ON,&channel,NULL,NULL,NULL,NULL,NULL);
DWORD retLen;
WORD wData;
ReadFile(me->m_hadc,&wData,sizeof(wData), &retLen,NULL);
BOOL ADC_IOControl(DWORD dwOpenContext,DWORD dwIOControlCode,LPBYTE lpInBuf,DWORD nInBufSize,LPBYTE lpOutBuf,DWORD nOutBufSize,LPDWORD lpBytesReturned)
//读ADC转换数据
DWORD ADC_Read(DWORD hOpenContext,LPVOID pBuffer,DWORD Count)
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As Integer
Public Declare Function DeviceIoControl Lib "kernel32" Alias "DeviceIoControl" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, lpInBuffer As Any, ByVal nInBufferSize As Integer, lpOutBuffer As Any, ByVal nOutBufferSize As Integer, lpBytesReturned As Integer, lpOverlapped As OVERLAPPED) As Integer
Public Declare Function ReadFile Lib "kernel32" Alias "ReadFile" (ByVal hFile As Integer, lpBuffer As Any, ByVal nNumberOfBytesToRead As Integer, lpNumberOfBytesRead As Integer, lpOverlapped As OVERLAPPED) As Integer
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const INVALID_HANDLE_VALUE = -1
'IO_ADC_ON这个定义没找到
public Const NULL = 0
public sub Foo()
dim channel as Integer = 0
m_hadc=CreateFile("ADC1:", GENERIC_READ
[解决办法]
GENERIC_WRITE, 0, NULL,OPEN_EXISTING, 0, 0)
if m_hadc = INVALID_HANDLE_VALUE then MessageBox.Show("Open ADC Driver error!")
DeviceIoControl(m_hadc,IO_ADC_ON,channel,NULL,NULL,NULL,NULL,NULL);
dim retLen as long
dim wData as integer
ReadFile(me->m_hadc,wData,Marsher.SizeOf(wData),retLen,NULL);
End Sub