⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.cpp

📁 一本在讲述USB驱动程式的书 及其范例原码
💻 CPP
字号:
// 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[])
	{							// main
	HANDLE hdevice = CreateFile("\\\\.\\PIOFAKE", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (hdevice == INVALID_HANDLE_VALUE)
		{
		printf("Can't open PIOFAKE device - %d\n", GetLastError());
		return 1;
		}

	DWORD junk;
	char* message = "Hello, world!";
	
	if (WriteFile(hdevice, message, strlen(message), &junk, NULL))
		printf("WriteFile succeeded, sent %d bytes\n", junk);
	else
		printf("WriteFile failed - %d\n", GetLastError());

	CloseHandle(hdevice);
	return 0;
	}							// main

⌨️ 快捷键说明

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