I have a custom driver I have written.
Here is the source code to communicate to the driver in C:
#include <windows.h>
#include <stdio.h>
/*********************************************************
* Main Function Entry
*
*********************************************************/
int _cdecl main(void)
{
HANDLE hFile;
DWORD dwReturn;
hFile = CreateFile("\\\\.\\Example", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if(hFile)
{
WriteFile(hFile, "Hello from user mode!", sizeof("Hello from use开发者_JAVA技巧r mode!"), &dwReturn, NULL);
CloseHandle(hFile);
}
return 0;
}
I want to be able to do this in .NET preferaly in VB.NET.
Does anyone know how to do the conversion?
The simplest is to use P/Invoke to OpenFile, WriteFile and CloseHandle.
You may find using the SerialPort class in the .net framework is easier. Check out the response to this question.
精彩评论