error C2275 : 'UNICODE_STRING' :illegal use of this type as an expression
2017-08-23 10:46
453 查看
真是个神奇的错误 :
我的代码是这样的:
#define MYDEVICE_DOS_DEVICE_NAME_W L"\\DosDevices\\myDevice"
//卸载设备
void Unload(IN PDRIVER_OBJECT pDriverObject)
{
KdPrint((" Unload Begin\n"));
//要先删除符号连接
UNICODE_STRING ustrDosDeviceName;
RtlInitUnicodeString(&ustrDosDeviceName, MYDEVICE_DOS_DEVICE_NAME_W);
IoDeleteSymbolicLink(&ustrDosDeviceName);
//再通过驱动对象删除设备对象
IoDeleteDevice(pDriverObject->DeviceObject);
KdPrint(("Unload End \n"));
}
按照C++的习惯,这是不会报错的,但因为公司要求驱动最好使用C语言编写,所以这时我就在阴沟里翻船了。
error C2275 : 'UNICODE_STRING' :illegal use of this type as an expression
必须要将这
UNICODE_STRING ustrDosDeviceName;
放入到函数体的首部,就不会报错了。
我的代码是这样的:
#define MYDEVICE_DOS_DEVICE_NAME_W L"\\DosDevices\\myDevice"
//卸载设备
void Unload(IN PDRIVER_OBJECT pDriverObject)
{
KdPrint((" Unload Begin\n"));
//要先删除符号连接
UNICODE_STRING ustrDosDeviceName;
RtlInitUnicodeString(&ustrDosDeviceName, MYDEVICE_DOS_DEVICE_NAME_W);
IoDeleteSymbolicLink(&ustrDosDeviceName);
//再通过驱动对象删除设备对象
IoDeleteDevice(pDriverObject->DeviceObject);
KdPrint(("Unload End \n"));
}
按照C++的习惯,这是不会报错的,但因为公司要求驱动最好使用C语言编写,所以这时我就在阴沟里翻船了。
error C2275 : 'UNICODE_STRING' :illegal use of this type as an expression
必须要将这
UNICODE_STRING ustrDosDeviceName;
放入到函数体的首部,就不会报错了。
相关文章推荐
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: ‘XXX’ : illegal use of this type as an expression 报错的解决方法!
- error C2275: "xxx"illegal use of this type as an expression
- 编译选项引发的ERROR C2275:illegal use of this type as an expression
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: 'FILE' : illegal use of this type as an expression
- error C2275 illegal use of this type as an expression 解决方法
- error C2275: 'FILE' : illegal use of this type as an expression
- error C2275! illegal use of this type as an expression
- error C2275: 'xxx' : illegal use of this type as an expression
- error C2275: 'time_t' : illegal use of this type as an expression
- C2275 illegal use of this type as an expression
- illegal use of this type as an expression 解决方案
- C语言编程调试:illegal use of this type as an expression错误解决办法
- illegal use of this type as an expression
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression
- illegal use of this type as an expression
- 'FILE' : illegal use of this type as an expression编译错误的解决
- illegal use of this type as an expression