请问关于imagehlp.dll中的getimageconfiginformation函数的问题

jcwKyl 2008-02-29 03:46:57
我的代码:


#pragma comment(lib,"imagehlp")


#include <iostream.h>
#include <windows.h>
#include <imagehlp.h>
#include <time.h>

int main() {
OPENFILENAME ofn;
TCHAR szFileName[MAX_PATH];
LOADED_IMAGE loadedImage;
BOOL bRet;
IMAGE_LOAD_CONFIG_DIRECTORY imageLoadedConfig;

memset(&ofn, 0, sizeof(ofn));
memset(szFileName, 0, sizeof(szFileName));

ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = TEXT("Executable Files(*.exe)\0*.exe\0DLL Files(*.dll)\0*.dllAll Files(*.*)\0*.*\0\0");
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;

GetOpenFileName(&ofn);

bRet = MapAndLoad(szFileName, NULL, &loadedImage, FALSE, TRUE);
if(bRet == FALSE) {
cout << "Error Ocuure in MapAndLoad\n";
}

bRet = GetImageConfigInformation(&loadedImage, &imageLoadedConfig);
if(bRet == FALSE) {
cout << "error ocuure in GetImageConfigInformation: "
            << GetLastError() << endl;
}


UnMapAndLoad(&loadedImage);

return 0;
}





其中的GetImageConfigInformation调用总是失败,但是GetLastError()却总是返回0.
请问问题出在什么地方了?另外,我试过在调用该函数前用CreateFile获得文件句柄给
loadedImage.hFile,或者在调用前memset(&imageLoadedConfig, 0 , sizeof(...))
但都不管用。


...全文
209 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
RAD Studio 10.2 Toyko Update2 10.2.2 KEYGEN 一键激活,安装时选择试用,安装完毕后一键激活即可。亲测可用!! Win10 Build 16299 旗舰版 亲测可用!!! 为了便于在 Lite 14.x 使用大侠们的特别补丁,初步写成这个:Activator.exe 他的主要作用: 1、整合 elseif、unis、x-force、cjack 大虾的 Keygen 相对原始部署方式,这个 Activator 实现“一键激活”! 使用方法: 1、执行 Activator.exe 发布历史: 2017.12.14 - v14.2 1、根据 25.0.28979.1978 原版制作,基于 RadStudioKeygenSourceCodeTokyo10.2Update2CorrectedSetup.zip 的成果 2017.08.11 - v14.1 1、根据 25.0.27659.1188 原版制作,基于 elseif-Rad-Studio-Keygen-master upto 10.2.1 的成果 2017.03.26 - v14.0 1、根据 25.0.26309.314 原版制作,基于 elseif、unis、x-force、cjack 等大虾的成果 已知问题: 1、在一些操作系统上如果出现安全提示,直接确定即可。 特别感谢: 1、elseif、unis、x-force、cjack、crackerjack、dr、freecat、gateway、huayan889、kerlingen、sinner、yuto 等大侠的特别补丁,感谢诸位我知道的不知道的的大虾们的辛勤劳动! 2、iny、nevergrief、snakejiao、star5、tintin1943、ti9er、wang_80919、wuxiangyang 等等我知道的不知道的的网友们的热情测试! 3、andreas hausladen 等大虾们的无私贡献! O(∩_∩)O~ Delphi 10.2 and C++Builder 10.2 Updata2 亲测可用! Embarcadero® C++Builder 10.2 Version 25.0.28979.1978 Copyright © 2017 Embarcadero Technologies, Inc. All Rights Reserved. advapi32.dll, 10.0.16299.15, C:\WINDOWS\System32\ AEPIC.dll, 10.0.16299.15, C:\WINDOWS\SYSTEM32\ androiddebugide250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ appanalytics250.bpl, 25.0.28979.1978, D:\Program Files (x86)\Embarcadero\Studio\19.0\bin\ apphelp.dll, 10.0.16299.98, C:\WINDOWS\SYSTEM32\ applet250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\bin\ asmview250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ ATL.DLL, 3.5.2284.0, C:\Windows\System32\ bcbandroid250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ bcbcoment250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ bcbcompro250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ bcbent250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\studio\19.0\Bin\ bcbfmxide250.bpl, 25.0.28979.1978, d:\program files (x86)\embarcadero\s

24,857

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧