zoukankan      html  css  js  c++  java
  • 获取句柄的方法总结(尤其是对于dll而言)

    /************************************************************
    *测试获取文件所在的模块的方法,其中GetModuleHandle是获取exe的
    *句柄,而后两者还可以用来获取dll模块的句柄
    *By IT05
    *2012-8-6 16:24:27
    *************************************************************/
    #include "stdafx.h"
    #include "windows.h"
    #include "_vcclrit.h"//定义了__ImageBase
    
    int _tmain(int argc, _TCHAR* argv[], TCHAR* env[])
    {
    	int i;
    
    	HMODULE hModule = ::GetModuleHandle(NULL);
    
    	_tprintf( TEXT("GetModuleHandle(NULL):0x%x\r\n"), hModule );
    
    	_tprintf( TEXT("__ImageBase=0x%x\r\n"), (HINSTANCE)&__ImageBase );
    
    	//_tmain处是说明本函数所在模块
    	//当是dll文件时,那么写dll模块内德函数即可得到dll的句柄
    	::GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (PCTSTR)_tmain, &hModule );
    
    	_tprintf( TEXT("GetModuleHandleEx:0x%x\r\n"), hModule );
    	
    	getchar();
    	return 0;
    }
    

  • 相关阅读:
    js快速排序
    蛇形数组
    大臣的旅费
    1724ROADS
    2738:实数加法
    完整版高精度计算(整理后的)
    2737:大整数除法
    2980:大整数乘法
    2736大整数减法,3180 整数减法
    2981:大整数加法
  • 原文地址:https://www.cnblogs.com/arbboter/p/4225251.html
Copyright © 2011-2022 走看看