碰到了一个超级怪异的问题,我用GetMonitorInfo这个函数链接不上,网上下了一个程序可以!

dawndu 2004-06-27 01:33:32
真的很奇怪,我用GetMonitorInfo,连接的时候报错error LNK2001: unresolved external symbol _xGetMonitorInfo@8,这个函数用的是user32.lib,可能有的朋友认为我的user32.lib太老,没有这个函数,可是我从网上找了一个用GetMonitorInfo这个函数的程序,别人的程序可是连接得好好的,我看了一下Setting里面连接的设置,也没有什么不同啊。别人的程序里面也没有用#prama comment这样的东西,我觉得很怪啊。不过可能说穿了是一个很简单的问题,可能还有很多我不知道的,大家发表点意见啊。不怕大家笑话,昨天被这个东西搞到半夜2点,怪!
...全文
658 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
needways 2004-06-27
  • 打赏
  • 举报
回复
我怎么无法回复短消息啊。

stub 是指存根函数,如果你的 user32.dll 中不支持要使用的 api 函数的话(用 GetProcAddress 来检测),就调用存根函数。
needways 2004-06-27
  • 打赏
  • 举报
回复
// multimon.h -- Stub module that fakes multiple monitor apis on Win32 OSes
// without them.
//
// By using this header your code will get back default values from
// GetSystemMetrics() for new metrics, and the new multimonitor APIs
// will act like only one display is present on a Win32 OS without
// multimonitor APIs.
//
// Exactly one source must include this with COMPILE_MULTIMON_STUBS defined.
//
// Copyright (c) 1985-1996, Microsoft Corporation
dawndu 2004-06-27
  • 打赏
  • 举报
回复
If you use these new API functions to make your applications multiple monitor-friendly, what will happen on systems running a version of Windows that does not have the multimonitor functions? (Neither Windows 95 nor Windows NT 4.0 includes the multiple-monitor APIs.) They will crash, unless you do something about it. The solution is a new header file, Multimon.h, which uses GetProcAddress to determine whether the relevant functions are actually in the system DLLs. If they are not, it supplies default implementations of these functions. This header file actually contains source code, and if the COMPILE_MULTIMON_STUBS flag is set, the code will be compiled. This means that you should define COMPILE_MULTIMON_STUBS in one--and only one--source file that includes Multimon.h. You can include Multimon.h in as many source files as you want, but make sure that COMPILE_MULTIMON_STUBS is defined in only one. The end result of this process is a single executable file that will run on all versions of Win32

如楼上那位兄弟所说,解决。我马上给分
needways 2004-06-27
  • 打赏
  • 举报
回复
加上我说的那个,就可以链接了。
dawndu 2004-06-27
  • 打赏
  • 举报
回复
不是编译不过,是链接不上啊
needways 2004-06-27
  • 打赏
  • 举报
回复

#pragma warning(disable:4706)
#define COMPILE_MULTIMON_STUBS
#include <multimon.h>
#pragma warning(default:4706)

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧