2

我写了一些使用以下内容的东西:

#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <commctrl.h>

此代码在安装了 Platform SDK 的 2 台机器上运行良好,但在 Windows 的全新安装(当然是 VM)上不能运行(无论是调试版本还是发布版本)。它以非常熟悉的方式死去:

---------------------------
C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe
---------------------------
C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

---------------------------
OK   
---------------------------

我怎样才能让它在全新安装上运行?它使用的是哪个 dll 却找不到?我的赌注是在 commctrl 上,但有人可以告诉我为什么不是每个窗口都这样吗?

此外,如果有人对如何调试这样的东西有提示,因为我的 CPP 已经生锈了,看起来:)

编辑 - 对我有用的是下载 Visual Studio 2008 的 Redistributable。我认为这不是一个好的解决方案 - 下载 2MB 文件并安装以运行简单的 11K 工具。我想我会更改代码以使用 LoadLibrary 从 comctl32.dll 获取我需要的 2 或 3 个函数。谢谢大家 :)

4

3 回答 3

5

Use Dependency Walker. Download and install from http://www.dependencywalker.com/ (just unzip to install). Then load up your executable. The tool will highlight which DLL is missing. Then you can find the redistributable pack which you need to ship with your executable.

If you use VS2005, most cases will be covered by http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en which includes everything needed to run EXEs created with VS2005. Using depends.exe you may find a more lightweight solution, though.

于 2008-09-30T21:39:20.447 回答
1

Common controls is a red herring. Your problem is that the Visual C++ 8.0 runtime - I assume you're using Visual Studio 2005 - isn't installed. Either statically link to the C/C++ runtime library, or distribute the runtime DLL.

You will have this problem with any C or C++ program that uses the DLL. You could get away with it in VS 6.0 as msvcrt.dll came with the OS from Windows 2000 up, and in VS.NET 2003 as msvcr71.dll came with .NET Framework 1.1. No more. Visual Studio 2005 and later use side-by-side assemblies to prevent DLL Hell, but that means you can't rely even on .NET 2.0 installing the exact version of C runtime that your program's built-in manifest uses. .NET 2.0's mscorwks.dll binds to version 8.0.50608.0 in its manifest; a VS-generated application binds to 8.0.50727.762 as of VS2005 SP1. My recollection is it used some pre-release version in the original (RTM) release of VS2005, which meant you had to deploy a Publisher Policy merge module if you were using the merge modules, to redirect the binding to the version actually in the released C run-time merge module.

See also Redistributing Visual C++ Files on MSDN.

于 2008-09-30T22:42:59.030 回答
0

我怀疑它正在尝试查找未安装的通用控件版本。您可能需要一个清单文件来将通用控件的版本映射到您的目标操作系统。此外,您可能需要确保安装了与您链接的相同 VC 运行时。

克里斯杰克逊博客

EDIT: A little searching and I've confirmed (mostly) that it is the version of your VC++ runtimes that is to blame. You need to distribute the versions that you built with. The platform SDK usually includes a merge module of these for that purpose, but there is often a VCRedist.exe for them as well. Try looking Microsoft's downloads.

KB94885

于 2008-09-30T21:35:52.530 回答