vfxgetmodulename.cpp
来自「获取文件的生产厂商和版本号信息」· C++ 代码 · 共 56 行
CPP
56 行
//-------------------------------------------------------------------------------
// Get Module Name class
// Get the module name given a module handle and process id.
//
// Designed and coded by Gene M. Angelo
// Copyright (c) 2001 Gene M. Angelo
//
// This code is made public domain by the author it may be used in products
// commercial or otherwise as long as all copyright notices remain in tact.
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
#include "stdafx.h"
#include <Psapi.h>
#include "VFXGetModuleName.h"
//-------------------------------------------------------------------------------
CVFXGetModuleName::CVFXGetModuleName()
{
}
//-------------------------------------------------------------------------------
CVFXGetModuleName::~CVFXGetModuleName()
{
}
//-------------------------------------------------------------------------------
bool CVFXGetModuleName::GetModuleName(CString& sModuleName, HANDLE hHandle /* = NULL*/, HMODULE hModule /* = NULL*/)
{
sModuleName = "";
// Get the process handle
if(! hHandle)
hHandle = ::GetCurrentProcess();
// Get the module handle
if(! hModule)
hModule = ::GetModuleHandle(NULL);
// Have to have process and module handle
if(! hHandle && ! hModule)
return false;
// Get the module name
LPTSTR p = sModuleName.GetBuffer(MAX_PATH + 1);
DWORD rc = GetModuleFileNameEx(hHandle, hModule, p, (DWORD)MAX_PATH);
// Release buffer
sModuleName.ReleaseBuffer();
return rc > 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?