Windows 已在 ****.exe 中触发一个断点。
Windows 已在 *****.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 *****.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 ****.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
输出窗口信息:
“GetData.exe”: 已加载“C:\Users\Administrator\Desktop\GetData-Source\GetData\Debug\GetData.exe”,已加载符号。
“GetData.exe”: 已加载“C:\Windows\System32\ntdll.dll”
“GetData.exe”: 已加载“C:\Windows\System32\kernel32.dll”
“GetData.exe”: 已加载“C:\Program Files\BMC Software\Patrol3\bin\pemapi80.dll”
“GetData.exe”: 已加载“C:\Program Files\BMC Software\common\smartsockets\bin\Windows-x86\msvcr80.dll”
“GetData.exe”: 已加载“C:\Windows\System32\msvcrt.dll”
“GetData.exe”: 已加载“C:\Windows\System32\user32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\gdi32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\advapi32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\rpcrt4.dll”
“GetData.exe”: 已加载“C:\Windows\System32\ws2_32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\nsi.dll”
“GetData.exe”: 已加载“C:\Program Files\BMC Software\Patrol3\bin\acmmls32_v280.dll”
“GetData.exe”: 已加载“C:\Windows\System32\wsock32.dll”
“GetData.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d\msvcr80.dll”
“GetData.exe”: 已加载“C:\Windows\System32\shlwapi.dll”
“GetData.exe”: 已加载“C:\Windows\System32\winspool.drv”
“GetData.exe”: 已加载“C:\Windows\System32\comdlg32.dll”
“GetData.exe”: 已加载“C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18000_none_886786f450a74a05\comctl32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\shell32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\ole32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\oleaut32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\odbc32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\shimeng.dll”
“GetData.exe”: 已加载“C:\Windows\System32\apphelp.dll”
“GetData.exe”: 已加载“C:\Windows\AppPatch\AcLayers.dll”
“GetData.exe”: 已加载“C:\Windows\System32\userenv.dll”
“GetData.exe”: 已加载“C:\Windows\System32\secur32.dll”
“GetData.exe”: 已加载“C:\Windows\System32\mpr.dll”
GetData.exe 中的 0x77a95dab 处最可能的异常: 0xC0000005: 读取位置 0x00000130 时发生访问冲突
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
GetData.exe 已触发了一个断点
GetData.exe 中的 0x77a39eed 处最可能的异常: 0xC0000142: DLL Initialization Failed
GetData.exe 中的 0x77a39eed 处未处理的异常: 0xC0000142: DLL Initialization Failed
GetData.exe 已触发了一个断点
GetData.exe 中的 0x73063ab6 处最可能的异常: 0xC0000005: Access violation
*** A stack buffer overrun occurred in "c:\Users\Administrator\Desktop\GetData-Source\GetData\Debug\GetData.exe" :
This is usually the result of a memory copy to a local buffer or structure where the size is not properly calculated/checked.
If this bug ends up in the shipping product, it could be a severe security hole.
The stack trace should show the guilty function (the function directly above __report_gsfailure).
*** enter .exr 77AF9310 for the exception record
*** then kb to get the faulting stack
Windows 已在 GetData.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 GetData.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 GetData.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
Windows 已在 GetData.exe 中触发一个断点。
其原因可能是堆被损坏,这说明 GetData.exe 中或它所加载的任何 DLL 中有 Bug。
原因也可能是用户在 GetData.exe 具有焦点时按下了 F12。
输出窗口可能提供了更多诊断信息。
程序“[5780] GetData.exe: 本机”已退出,返回值为 -1073740791 (0xc0000409)。
贴上代码:
// GetData.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "GetData.h"
#include "pemapi.h"
#include "Equipment.h"
#include "Parameter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
PemnCommHandle ConnectAgent(CString EquName, int Port, CString UserName, CString Pass);
double GetValue(PemnCommHandle agentHandle, CString AppType, CString AppInst, CString Param);
PemnCommHandle CloseAgent(PemnCommHandle agentHandle);
static void _MyDisconnectCallback(PemnCommHandle hComm, PemnClientData pClientData)
{
printf("_MyDisconnectCallback called: hComm is now invalid\n");
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
int nDebug = 1;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
CEquipment Equipment;
CParameter Parameter;
CString sql;
CString message;
PemnCommHandle agentHandle;
int nEquCount=0, nParCount=0;
double d_Value;
while (Equipment.Open()) //每三秒取一次数据
{
if (nDebug)
{
nEquCount = 0;
message = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S \tBegin to get value.");
cout << message.GetBuffer(message.GetLength()) << endl;
}
while (!Equipment.IsEOF()) //取有效的设备信息
{
if (nDebug)
{
nParCount = 0;
message.Format(" %s\tGetting %s value...",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
Equipment.m_EQUNAME
);
cout << message.GetBuffer(message.GetLength()) << endl;
}
agentHandle = NULL;
sql.Format("SELECT * FROM T_PARAMETER WHERE EQUNAME='%s' AND ISACTIVE=1", Equipment.m_EQUNAME );
Parameter.SetSQL(sql);
if (!Parameter.Open())
{
message.Format(" ERROR(%s):\tCan not open t_Parameter!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
cout << message.GetBuffer(message.GetLength()) << endl;
}
else if (agentHandle = ConnectAgent(Equipment.m_SITE,
Equipment.m_PORT,
Equipment.m_USERNAME,
Equipment.m_PASS))//取此设备的参数信息,并打开与此设备的AGENT的连接
{
while (!Parameter.IsEOF()) //循环取设备的监控参数
{
d_Value = GetValue(agentHandle,
Parameter.m_APPTYPE,
Parameter.m_APPINST,
Parameter.m_PARAM);
Parameter.Edit();
Parameter.m_PARMVALUE = d_Value;
Parameter.Update(); //将取到的参数值写入表中
if (Parameter.m_PARMVALUE==-1)
break;
Parameter.MoveNext();//取下一个有效参数
nParCount++;
}
Parameter.Close(); //关闭此设备的参数表
CloseAgent(agentHandle); //断开与此设备的AGENT的连接
if (nDebug)
{
message.Format(" %s\tGetted %i Parameters of %s.",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
nParCount,
Parameter.m_EQUNAME
);
cout << message.GetBuffer(message.GetLength()) << endl ;
}
}
else
{
Parameter.Close();
message.Format(" ERROR(%s):\tCan not connect to agent(%s)!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
Equipment.m_EQUNAME);
cout << message.GetBuffer(message.GetLength()) << endl;
}
Equipment.MoveNext(); //取下一个有效设备信息
nEquCount++;
}
Equipment.Close();
if (nDebug)
{
message.Format("%s \tEnd to get %i equipments' parameter.",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
nEquCount);
cout << message.GetBuffer(message.GetLength()) << endl<< endl;
}
Sleep(3000);
}
}
return nRetCode;
}
PemnCommHandle ConnectAgent(CString EquName, int Port, CString UserName, CString Pass)
{
CString Encrypted;
CString sResult;
PemnCommHandle agentHandle;
CString message;
//对口令加密
if (!PemnEncrypt(Encrypted.GetBuffer(127),
126,
Pass.GetBuffer(Pass.GetLength())
)
)
{
//如果失败,返回NULL。
message.Format(" ERROR(%s):\tCan not encrypt password!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
cout << message.GetBuffer(message.GetLength()) << endl;
return NULL;
}
//打开连接
sResult = PemnBOpen(&agentHandle,
EquName.GetBuffer(EquName.GetLength()),
Port,
UserName.GetBuffer(UserName.GetLength()),
Encrypted.GetBuffer(Encrypted.GetLength()),
1,
_MyDisconnectCallback,
NULL);
if (sResult.Compare(PEMA_OK)) //如果失败,返回NULL
{
message.Format(" ERROR(%s):\tCan not connect to agent(%s)!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
sResult);
cout << message.GetBuffer(message.GetLength()) << endl;
return NULL;
}
return agentHandle;
}
double GetValue(PemnCommHandle agentHandle, CString AppType, CString AppInst, CString Param)
{
CString sResult;
CString message;
PemnParamObjHandle hObject;
PemnParamAttrArray *pParamAttr;
if (!agentHandle)
{
message.Format(" ERROR(%s):\tDisconnect from agent when get value!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"));
cout << message.GetBuffer(message.GetLength()) << endl;
return -1;
}
hObject = PemnBGetParamObj(agentHandle,
AppType.GetBuffer(AppType.GetLength()),
AppInst.GetBuffer(AppInst.GetLength()),
Param.GetBuffer(Param.GetLength()),
USE_DEFAULT_TIMEOUT);
pParamAttr = PemnGetParamObjAttributes(hObject);
if (pParamAttr)
{
return atof((*pParamAttr)[4]);
}
else
{
message.Format(" ERROR(%s):\tGet %s/%s/%s value error!",
CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"),
AppType, AppInst, Param);
cout << message.GetBuffer(message.GetLength()) << endl;
return -2;
}
}
PemnCommHandle CloseAgent(PemnCommHandle agentHandle)
{
PemnBClose(agentHandle);
return NULL;
}
各位大神帮忙看看啊,生成可以通过,调试的话不管是DEBUG还是RELEASE都会出现错误,没有进入MAIN函数。