请问关于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(...))
但都不管用。


...全文
227 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

24,856

社区成员

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

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