如何初始化msvcrt.dll?

发布于 2024-10-07 06:41:15 字数 306 浏览 0 评论 0原文

如果我执行 LoadLibrary("msvcrt.dll"),我是否需要以某种方式初始化 CRT?以下文档中的第 2 节似乎说我这样做,但当我尝试调用 _CRT_INIT 时,我只是收到 _CRT_INIT 的未定义符号错误:

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

编辑:我应该说这是一个动态加载它使用的所有 dll 的程序,因此调用 LoadLibrary( “msvcrt.dll”)。

If I do a LoadLibrary("msvcrt.dll") do I need to initialize the CRT somehow? Section 2 in the following document seems to say that I do, but I just get an undefined symbol error for _CRT_INIT when I try to call _CRT_INIT:

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

Edit: I should have said that this is for a program that dynamically loads all the dlls that it uses, hence the call to LoadLibrary("msvcrt.dll").

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

望笑 2024-10-14 06:41:15

在其中调用DllMain()。如果它依赖于C运行时,它将调用CRT_INIT。

但更好的问题是,如果程序正在使用 msvcrt 中的某些内容,则无需显式加载 dll 并初始化它,那么为什么要这样做呢?

Call DllMain() in it. If it relies on the C runtime, it will call CRT_INIT.

But a far better question is if a program is using something in msvcrt, there's no need to explicitly load the dll and initialize it, so why are you doing this?

孤凫 2024-10-14 06:41:15

如果您使用 C++,您是否将 _CRT_INIT 声明为 extern "C"

您是否尝试过使用 DUMPBIN 实用程序 ( http://support.microsoft.com/ kb/177429 - 如果您自己没有设置 PATH,我认为您必须使用 Visual Studio 命令提示符)和 /EXPORTS 切换查看 CRT DLL 中有哪些函数可用,只是为了仔细检查?

如果您遇到困难,VS2005 及更早版本(可能是更高版本...)提供了运行时库的源代码。对于 VS2005,它位于 VC/crt/src 中,相对于 VS 安装文件夹。看起来 _CRT_INIT 是正确的名称 - 请参阅 crtdll.cdllcrt0.c,它是一个 C 函数。

If you're working in C++, have you declared _CRT_INIT as extern "C"?

Have you tried using the DUMPBIN utility ( http://support.microsoft.com/kb/177429 -- if you haven't your PATH up yourself, you'll have to use the Visual Studio Command Prompt I think) with the /EXPORTS switch to see which functions are available from the CRT DLL, just to double check?

If you get stuck, VS2005 and earlier (and presumably later...) come supplied with the source code for the runtime library. For VS2005, this is in VC/crt/src, relative to the VS install folder. It looks like _CRT_INIT is the right name -- see crtdll.c and dllcrt0.c, and it's a C function.

冷情 2024-10-14 06:41:15

您不得调用 _CRT_INIT(),而应调用 CRT_INIT()(如果您确实必须这样做)

You must not call _CRT_INIT() but call CRT_INIT() (if you really must)

一瞬间的火花 2024-10-14 06:41:15

您引用的链接指的是仅在“构建 DLL 时使用 CRT 库”时才使用 CRT_INIT(),即使如此,它也只是两种选择之一;在大多数情况下,第一个可能更可取。

The link you referenced refers to using CRT_INIT() only when "Using the CRT Libraries When Building a DLL", and even then it is only one of two alternatives; the first probably being preferable in most cases.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文