本文介绍了如何从 DLL 获取 HINSTANCE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 VC++ 中创建了一个 DLL 作为 Win32 项目

I have created a DLL in VC++ as Win32 project

DLLMAIN 函数是

DLLMAIN function is

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    return TRUE;
}

现在我需要 DLL 的 HINSTANCE,它需要传递给 Win32 函数.

Now I need HINSTANCE of the DLL , that need to be passed to Win32 functions.

HMODULE 和 HINSTANCE 是否相同?

Are HMODULE and HINSTANCE same?

我如何获得 HINSTANCE?

How can I get HINSTANCE?

推荐答案

摘自 Windows Via C/C++ [1] 一书

An excerpt from the book Windows Via C/C++ [1]

注意 事实证明,HMODULEs 和 HINSTANCEs 是完全一样的东西.如果函数的文档表明需要 HMODULE,则可以传递 HINSTANCE,反之亦然.有两种数据类型,因为在 16 位 Windows 中 HMODULEs 和 HINSTANCEs 标识了不同的东西

[1] Richter、Jeffery 和 Nasarre、Christophe,Windows Via C/C++,第 5 版,Redmond:Microsoft Press 2008,第 74 页

[1] Richter, Jeffery and Nasarre, Christophe, Windows Via C/C++, 5th ed, Redmond: Microsoft Press 2008, pp. 74

这篇关于如何从 DLL 获取 HINSTANCE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 07:43