Michael Eakins
Michael Eakins

Reputation: 4179

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?

Upvotes: 1

Views: 82

Answers (2)

semaj
semaj

Reputation: 1575

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

Upvotes: 1

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

Upvotes: 1

Related Questions