模块“executable.exe”中的地址发生访问冲突。读取地址
我在网上读到了一些“访问冲突”的问题,但这对我来说很奇怪
我已经测试了一些“解决方案”但没有结果
这是一段代码:
TDateTime CFileVersionInfo::GetFileDate() const
{
FILETIME local;
SYSTEMTIME st;
TDateTime res;
FILETIME ft;
ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
FileTimeToLocalFileTime(&ft, &local);
FileTimeToSystemTime(&local, &st) ;
//GetLocalTime(st);
res = SystemTimeToDateTime(st) ;
return res;
}
我可以毫无问题地制作或构建程序,但是当我运行程序时,它会显示访问冲突错误,如果我评论该函数:
// TDateTime dateTime = fvi.GetFileDate();
程序运行完美
我不是 C++ 专业人士我只是想制作一个供个人使用的程序,所以我向专家提出这个问题
编辑:
我已经解决了 问题
TDateTime CFileVersionInfo::GetFileDate() const
{
_FILETIME local;
_SYSTEMTIME st;
TDateTime res;
FILETIME ft;
ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
FileTimeToLocalFileTime(&ft, &local);
FileTimeToSystemTime(&local, &st) ;
GetLocalTime(&st); // <-- This is the solution.. for now...
res = SystemTimeToDateTime(st) ;
return res;
}
I've read some problems with "Access Violation" on the net but this is very weird for me
I have tested some "solutions" but with no results
This is the piece of code:
TDateTime CFileVersionInfo::GetFileDate() const
{
FILETIME local;
SYSTEMTIME st;
TDateTime res;
FILETIME ft;
ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
FileTimeToLocalFileTime(&ft, &local);
FileTimeToSystemTime(&local, &st) ;
//GetLocalTime(st);
res = SystemTimeToDateTime(st) ;
return res;
}
I can Make or Build the program with no problems but when I run the program it show me the Access Violation error, if I comment the function:
// TDateTime dateTime = fvi.GetFileDate();
The program run perfectly
I'm not a C++ pro I just want to make a program for personal use so I ask this question to expert
EDIT:
I've resolved the problem
TDateTime CFileVersionInfo::GetFileDate() const
{
_FILETIME local;
_SYSTEMTIME st;
TDateTime res;
FILETIME ft;
ft.dwLowDateTime = m_FileInfo.dwFileDateLS;
ft.dwHighDateTime = m_FileInfo.dwFileDateMS;
FileTimeToLocalFileTime(&ft, &local);
FileTimeToSystemTime(&local, &st) ;
GetLocalTime(&st); // <-- This is the solution.. for now...
res = SystemTimeToDateTime(st) ;
return res;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有执行任何错误检查来确保 API 转换成功,因此您可能正在尝试转换垃圾数据。始终检查错误,例如:
You are not doing any error checking to make sure the API conversions are succeeding, so you could be trying to convert trash data. Always check for errors, eg:
我已经解决了问题
I've resolved the problem