AfxGetInstanceHandle & AfxGetResourceHandle

本文介绍了MFC中的两个重要函数:AfxGetInstanceHandle和AfxGetResourceHandle。AfxGetInstanceHandle用于获取当前应用程序实例的句柄,而AfxGetResourceHandle则返回加载应用程序默认资源的句柄。文章通过示例展示了如何使用这两个函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AfxGetInstanceHandle

This function allows you to retrieve the instance handle of the current application.

HINSTANCE AFXAPI AfxGetInstanceHandle( );

Return Value

An HINSTANCE to the current instance of the application. If called from within a DLL linked with the USRDLL version of MFC, an HINSTANCE to the DLL is returned.

Remarks

AfxGetInstanceHandle always returns the HINSTANCE of your executable file (.EXE) unless it is called from within a DLL linked with the USRDLL version of MFC. In this case, it returns an HINSTANCE to the DLL.

Example

C++

// Print the application instance handle to the debugger output window.
TRACE(_T("Application instance handle is 0x%0X\n"), AfxGetInstanceHandle());

http://technet.microsoft.com/zh-cn/library/36z3tfsb%28v=vs.100%29.aspx



AfxGetResourceHandle


extern HINSTANCE AfxGetResourceHandle( );

Return Value

An HINSTANCE handle where the default resources of the application are loaded.

Example

C++

//Load the menu specifying the module handle where resource is to be 
//found & resource ID
HMENU hMenu = ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));

http://technet.microsoft.com/zh-cn/library/zaewt3xs%28v=vs.100%29.aspx

转载于:https://my.oschina.net/ajian2014/blog/283264

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值