代码是这样的: 
hDevice = CreateFile(TEXT("\\\\.\\slDRIVER1_DeviceName"), // drive 
0, // no access to the drive 
FILE_SHARE_READ | // share mode 
FILE_SHARE_WRITE, 
NULL, // default security attributes 
OPEN_EXISTING, // disposition 
0, // file attributes 
NULL); // do not copy file attributes 
if(hDevice!=INVALID_HANDLE_VALUE) MessageBox(_T("loaded")); 
DWORD length; 
BOOL ret = DeviceIoControl(hDevice, 
MY_DVC_IN_CODE, 
// 功能号 
in_buffer, 
// 输入缓冲,要传递的信息,预先填好 
in_buffer_len, 
// 输入缓冲长度 
NULL, 
// 没有输出缓冲 
0, 
// 输出缓冲的长度为 0 
&length, 
// 返回的长度 
NULL); 
if(ret)MessageBox(_T("ok")); 
MY_DVC_IN_CODE在驱动和应用中自定义的。 
我不知道为什么调用deviceiocontrol不成功,createfile成功了,getlasterror()=5,请高手指点。