开发者

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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜