calldriver.c

来自「aesop s3c2440a BSP for windowsce 6.0」· C语言 代码 · 共 40 行

C
40
字号
#include <windows.h>

#define METHOD_BUFFERED                 0
#define FILE_ANY_ACCESS                 0
#define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
    ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)

#define IOCTL_SAMPLE_FIRST	CTL_CODE( 0, 0x800, 0, 0 )

int WINAPI
main (
    HINSTANCE hInstance, 
    HINSTANCE hInstPrev, 
    LPWSTR pCmdLine,
    int nCmdShow)
{
    HANDLE handle;
	DWORD ret;
	unsigned char Buffer[10]="AAAAAAAAAA";

	handle = CreateFile(
		L"SAM1:", 
		GENERIC_READ|GENERIC_WRITE,
		0,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL
		);

	WriteFile( handle, Buffer, 10, &ret, NULL );

	DeviceIoControl( handle, IOCTL_SAMPLE_FIRST, NULL, 0, NULL, 0, &ret, NULL );

	CloseHandle( handle );

    return(0);
}

⌨️ 快捷键说明

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