我在我的程序中获取当前系统所有的窗口的所属模块的名称:
void CTestWndsDlg::OnGetwnd()
{
m_listCtrl.DeleteAllItems();
::EnumWindows(EnumProc, (LPARAM)&m_listCtrl);}BOOL CALLBACK CTestWndsDlg::EnumProc(HWND hwnd, LPARAM lpMsg)
{
....
TCHAR ModuleName[255];
::GetWindowModuleFileName(m_hwnd, ModuleName,255 );
....
}
编译出现错误:
E:\relative\TestWnds\TestWndsDlg.cpp(198) : error C2039: 'GetWindowModuleFileName' : is not a member of '`global namespace''
E:\relative\TestWnds\TestWndsDlg.cpp(198) : error C2065: 'GetWindowModuleFileName' : undeclared identifier
一看msdn知道GetWindowModuleFileName运行需要
Function InformationHeader Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 4.0 SP3
Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP
应该是没有问题啊!难道是winuser.h被我改了,一看文件修改时间并没有!
没办法include<winuser.h>还是说未定义。
再看一下GetWindowModuleFileName的定义:
WINUSERAPI UINT WINAPI
GetWindowModuleFileNameA(
HWND hwnd,
LPSTR pszFileName,
UINT cchFileNameMax);
WINUSERAPI UINT WINAPI
GetWindowModuleFileNameW(
HWND hwnd,
LPWSTR pszFileName,
UINT cchFileNameMax);
#ifdef UNICODE
#define GetWindowModuleFileName GetWindowModuleFileNameW
#else
#define GetWindowModuleFileName GetWindowModuleFileNameA
#endif // !UNICODE
将他拷贝到我的工程中,这次编译没错,链接出错了:
Linking...
TestWndsDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) unsigned int __stdcall GetWindowModuleFileNameA(struct HWND__ *,char *,unsigned int)" (__imp_?GetWindowModuleFileNameA@@YGIPAUHWND__@@PADI@Z)
Debug/TestWnds.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
TestWnds.exe - 2 error(s), 0 warning(s)
费解!!!
附:我在不同的vc6。0,2000/98上测试过!
void CTestWndsDlg::OnGetwnd()
{
m_listCtrl.DeleteAllItems();
::EnumWindows(EnumProc, (LPARAM)&m_listCtrl);}BOOL CALLBACK CTestWndsDlg::EnumProc(HWND hwnd, LPARAM lpMsg)
{
....
TCHAR ModuleName[255];
::GetWindowModuleFileName(m_hwnd, ModuleName,255 );
....
}
编译出现错误:
E:\relative\TestWnds\TestWndsDlg.cpp(198) : error C2039: 'GetWindowModuleFileName' : is not a member of '`global namespace''
E:\relative\TestWnds\TestWndsDlg.cpp(198) : error C2065: 'GetWindowModuleFileName' : undeclared identifier
一看msdn知道GetWindowModuleFileName运行需要
Function InformationHeader Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 4.0 SP3
Unicode Implemented as Unicode and ANSI versions on Windows NT, Windows 2000, Windows XP
应该是没有问题啊!难道是winuser.h被我改了,一看文件修改时间并没有!
没办法include<winuser.h>还是说未定义。
再看一下GetWindowModuleFileName的定义:
WINUSERAPI UINT WINAPI
GetWindowModuleFileNameA(
HWND hwnd,
LPSTR pszFileName,
UINT cchFileNameMax);
WINUSERAPI UINT WINAPI
GetWindowModuleFileNameW(
HWND hwnd,
LPWSTR pszFileName,
UINT cchFileNameMax);
#ifdef UNICODE
#define GetWindowModuleFileName GetWindowModuleFileNameW
#else
#define GetWindowModuleFileName GetWindowModuleFileNameA
#endif // !UNICODE
将他拷贝到我的工程中,这次编译没错,链接出错了:
Linking...
TestWndsDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) unsigned int __stdcall GetWindowModuleFileNameA(struct HWND__ *,char *,unsigned int)" (__imp_?GetWindowModuleFileNameA@@YGIPAUHWND__@@PADI@Z)
Debug/TestWnds.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
TestWnds.exe - 2 error(s), 0 warning(s)
费解!!!
附:我在不同的vc6。0,2000/98上测试过!
解决方案 »
- 【求助】关于窗口控件刷新问题
- vc2008 配置的简单问题!!
- 利用RTC实现待机转入休眠。。。。
- 问个类型强制转换,为什么同样都是 void* 转 long 一个是警告,运行正常;另一个是错误?
- 我的程序设为静态链接到mfc库,那请问在运行时库的选择上用/MD链接的程序和/MT链接的程序有什么不同?性能上?大小上?运行时的附加库的需求
- 在对话框框中创建的菜单如何响映UPDATE_COMMAND_UI的消息?谢谢
- 请问,谁有《Visual C++ 串口通信工程开发实例导航》的电子书?谢谢
- select模型 服务器端如何检测客户端socket是否关闭?
- MFC下打印预览如何实现?
- 串口问题 我是新手请大家帮忙指点一下
- 视频播放多画面显示!
- OLE,ActiveX,COM是什么关系?
#define WINVER 0x0500
#include <afxwin.h>