I need help converting my driver user interface code

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 user 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?

Answers


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.


Need Your Help

correct scrollViewWillEndDragging code?

ios xcode swift uiscrollview uicollectionview

How do I get the UIScrollView to stop dragging at the end of the view, and snap it into a correct position? I've attempted using the following code, but while it correctly decelerates, and snaps in...