1

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?

2 Answers 2

1

The simplest is to use P/Invoke to OpenFile, WriteFile and CloseHandle.

1

You may find using the SerialPort class in the .net framework is easier. Check out the response to this question.

1
  • This really isn't relevant to the question. Dec 3, 2010 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.