标签存档: Windows

VS2008:error C2259 cannot instantiate abstract class

Visual Studio2008编译错误error C2259 cannot instantiate abstract class

经过检查,发现源代码中确实已经派生了虚函数,派生的虚函数源文件也正常编译。

最后在微软的官方网站上找到了答案(可能只是error C2259其中一种可能的原因,供参考):

This behavior is by design with VS 2005. The root cause is because wchar_t is a different type than unsigned short though in prior versions of Visual C++, the compiler considered them to be the same type. In this sample code, the type library uses unsigned short but the C++ source files use wchar_t. So the types don’t match therefore the functions that contain these types in their signatures don’t override the interface.

在VS 2005/VS2008中,wchar_t和unsigned short是不同的类型,尽管在之前的Visual C++版本中编译器将两者视为了相同的类型。由于参数类型的不匹配导致编译器无法正确地识别或编译重载的接口。

To continue working with this sample, either correct the type mismatch or use the /Zc:wchar_t- compiler switch to force the compiler to consider wchar_t the same type as unsigned short.
In the VS 2005 project property properties, under the C/C++ node, select Language. Then change “Treat wchar_t as Built-In Type” from “Yes” to “No”.
解决办法:使用/Zc:wchar_t-编译选项强制让编译器将wchar_t 和 unsigned short视为相同类型。或者在VS 2005/VS2008中,将项目属性中将”Treat wchar_t as Built-In Type”一项设置为”No”.

微软相关链接地址:

http://connect.microsoft.com/VisualStudio/feedback/details/101072/error-c2259-cannot-instantiate-abstract-class#

Visual Studio LNK2005 error

环境:  Visual Studio 2008 C++

编译错误: error LNK2005: _DllMain@12 already defined …

The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked.

微软的支持文档指出,MFC库的链接必须在CRT库之前,而解决方法有2种:

1. 强制连接器以正确的顺序链接,具体方法见下面的微软链接。

2. 在Linker标签页中,找到Command Line属性,并添加附加选项: /verbose:lib,重新编译工程,工程会列出详细的库清单,根据输出的内容来修正有问题的组件。

其中如果使用的是MFC库,确保每一个工程文件都包含头文件 #include <Stdafx.h>。

http://support.microsoft.com/kb/148652

Windows XP系统关闭CD ROM的Auto-Play(自动播放)

微软文档:
How to disable the Autorun functionality in Windows
方法一,通过组策略设置(注意:Windows XP HOME不支持):

How to use Group Policy settings to disable all Autorun features in Windows Server 2003, Windows XP Professional, and Windows 2000

  1. Click Start, click Run, type Gpedit.msc in the Open box, and then click OK.
  2. Under Computer Configuration, expand Administrative Templates, and then click System.
  3. In the Settings pane, right-click Turn off Autoplay, and then click Properties.

    Note In Windows 2000, the policy setting is named Disable Autoplay.

  4. Click Enabled, and then select All drives in the Turn off Autoplay box to disable Autorun on all drives.
  5. Click OK to close the Turn off Autoplay Properties dialog box.
  6. Restart the computer.

方法二,通过注册表(所有XP系统有效,但是要修改注册表,这个操作有一定风险,请操作前备份好注册表。):

How to disable all Autorun features in Windows XP Home Edition and other operating systems.

For operating systems that do not include Gpedit.msc, follow these steps:

  1. Click Start, click Run, type regedit in the Open box, and then click OK.
    点击”开始“按钮,点击”运行“,在运行对话框中输入”regedit “, 然后点击”确定“。
  2. Locate and then click the following entry in the registry:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDriveTypeAutorun
    定位到如下注册表键值:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDriveTypeAutorun
  3. Right-click NoDriveTypeAutoRun, and then click Modify.
    右键选择”NoDriveTypeAutoRun“这个键,然后点击”修改“。
  4. In the Value data box, type 0xFF to disable all types of drives. Or, to selectively disable specific drives, use a different value as described in the “How to selectively disable specific Autorun features” section.
    在弹出的键值修改对话框中,把原来的值修改为0xFF。或者用不同的值来有选择性地禁用指定驱动器,详见”How to selectively disable specific Autorun features”章节。
  5. Click OK, and then exit Registry Editor.
    点击确定,然后退出注册表编辑器。
  6. Restart the computer.
    重启计算机,使设置生效。

Canonical URL by SEO No Duplicate WordPress Plugin