我一段代码在A里可以用,用的时候要加文件头,但是我把这段代码加到B中的时候,运行时出错,并且出的错和把A中的文件头注释后出的错差不多,请问谁知道这是怎么回事啊?
我加了头文件#include "Dbt.h",但是执行的时候老说
error C2065: 'DEV_BROADCAST_DEVICEINTERFACE' : undeclared identifier
我加了头文件#include "Dbt.h",但是执行的时候老说
error C2065: 'DEV_BROADCAST_DEVICEINTERFACE' : undeclared identifier
解决方案 »
- 菜鸟请教 VC2010,40分恭候!
- 局域网扫描?
- Invalidate()位置问题
- 我想用VC做个dll,供PB中调用,主要功能是画直线.该怎么实现?
- 急问 关于广东远光软件股份有限公司的情况 进者有分
- 给分了!60分!哪位能提供关于bmp图像操作的代码?
- 帮我看看创建ADO数据库操作的DLL时出现的编译错误。
- 在tab control上放的group Box和Picture控件都无法调整大小和位置?
- 建议到这里来的人先学好语文
- GetProcAddress不能返回 CALLBACK 函数地址?
- 如何将长整型数组转换成字符串.或者转换成CHAR数组也可以???
- 双缓冲防图片刷新闪烁问题--内存泄漏4K
'DEV_BROADCAST_DEVICEINTERFACE'
这个是微软的基础类库里的啊,不用自己定义的, 只要加了#include "Dbt.h"就可以的
我就是不知道为什么会出这样的错误
可能是这个问题:
在以前的工程中定义了.h文件
然后又定义了一遍因为.h文件中大多会有怎么一句
#ifndefine ...._H_
#define ..._H_
可能是这样
我是要把A的功能在B里实现,我就把A的主要代码都拷到B里了啊
DWORD dbcc_size;
DWORD dbcc_devicetype;
DWORD dbcc_reserved;
GUID dbcc_classguid;
TCHAR dbcc_name[1];
} DEV_BROADCAST_DEVICEINTERFACE *PDEV_BROADCAST_DEVICEINTERFACE;
就是把这复制过去是吧?
好象没用
DWORD dbcc_size;
DWORD dbcc_devicetype;
DWORD dbcc_reserved;
GUID dbcc_classguid;
TCHAR dbcc_name[1];
} DEV_BROADCAST_DEVICEINTERFACE, *PDEV_BROADCAST_DEVICEINTERFACE;
中间有个逗号
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(187) : error C2146: syntax error : missing ';' before identifier 'dbi'
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(187) : error C2065: 'dbi' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(189) : error C2228: left of '.dbcc_size' must have class/struct/union type
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(190) : error C2228: left of '.dbcc_devicetype' must have class/struct/union type
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(190) : error C2065: 'DBT_DEVTYP_DEVICEINTERFACE' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(191) : error C2228: left of '.dbcc_reserved' must have class/struct/union type
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(192) : error C2228: left of '.dbcc_classguid' must have class/struct/union type
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2065: 'HDEVNOTIFY' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2146: syntax error : missing ';' before identifier 'hDevNotify'
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2065: 'hDevNotify' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(196) : error C2065: 'RegisterDeviceNotification' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(199) : error C2065: 'DEVICE_NOTIFY_WINDOW_HANDLE' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(547) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(552) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(571) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(627) : warning C4018: '<' : signed/unsigned mismatch
Generating Code...
Error executing cl.exe.
Creating browse info file...TimeClock.exe - 13 error(s), 4 warning(s)
没加之前是上面的错误,加了之后
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(190) : error C2065: 'DBT_DEVTYP_DEVICEINTERFACE' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2065: 'HDEVNOTIFY' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2146: syntax error : missing ';' before identifier 'hDevNotify'
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(194) : error C2065: 'hDevNotify' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(196) : error C2065: 'RegisterDeviceNotification' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(199) : error C2065: 'DEVICE_NOTIFY_WINDOW_HANDLE' : undeclared identifier
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(547) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(552) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(571) : warning C4018: '<' : signed/unsigned mismatch
C:\Documents and Settings\goodo\桌面\GoodoEastRiver3\TimeClockDlg.cpp(627) : warning C4018: '<' : signed/unsigned mismatch
Generating Code...
Error executing cl.exe.
Creating browse info file...TimeClock.exe - 6 error(s), 4 warning(s)
出错的地方代码为
InitEditBox(); GUID hid_guid={0x4D1E55B2,0xF16F,0x11CF,0x88,0xCB,0x00,0x11,0x11,0x00,0x00,0x30};
DEV_BROADCAST_DEVICEINTERFACE dbi;
ZeroMemory(&dbi,sizeof(dbi));
dbi.dbcc_size=sizeof(dbi);
dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
dbi.dbcc_reserved = 0;
dbi.dbcc_classguid = hid_guid; HDEVNOTIFY hDevNotify; hDevNotify = RegisterDeviceNotification(m_hWnd,
&dbi,
DEVICE_NOTIFY_WINDOW_HANDLE
); if(!hDevNotify)
{
int Err = GetLastError();
printf( "RegisterDeviceNotification failed: %lx.\n", Err);
return FALSE;
}
在StdAfx.h添加
#define WINVER 0x0500
具体参考http://blog.5d.cn/user18/sphinxzh/200612/336888.html