test.cpp

来自「Programming WDM 2st 配套源码」· C++ 代码 · 共 27 行

CPP
27
字号
// test.cpp : Defines the entry point for the console application.
// Copyright (C) 1999 by Walter Oney
// All rights reserved

#include "stdafx.h"

int main(int argc, char* argv[])
	{
	HANDLE hfile = CreateFile("\\\\.\\PCI42", GENERIC_READ | GENERIC_WRITE, 0,
		NULL, OPEN_EXISTING, 0, NULL);
	if (hfile == INVALID_HANDLE_VALUE)
		{
		puts("Can't open PCI42 device");
		return 1;
		}

	BYTE answer;
	DWORD numread;
	if (ReadFile(hfile, &answer, 1, &numread, NULL))
		printf("The answer is %d\n", answer);
	else
		printf("ReadFile failed - %d\n", GetLastError());

	CloseHandle(hfile);
	return 0;
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?