473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Windows application crashing on a single machine

HI All,
I have created a MFC exe using VC++ .NET 2003 on Windows XP Prof
service pack 2 and it works properly on my machine, but when I run the
same exe on a different machine (Windows XP Prof SP-2), The application

is bought up and after some time its throwing a windows xp error dialog

box saying,

I am also running the same application on 2 more machines there
everything works fine.

Here is thr Windows XP error dialog box that appreas when its crashed
TODO: <File descriptionhas encountered a problem and needs to close.
We are sorry for any inconenience.

If you are in the middle of something, the information you were working

on might be lost.
Please tell Microsoft about this problem.
blab blah....
I have function called OnNotifyNewData (WPARAM wParam, LPARAM lParam)
which appreas to be cauing the problem. When I run the application
commenting this function its didnt crashed.

LRESULT CUserViewFrame::OnNotifyNewData (WPARAM wParam, LPARAM lParam)
{
const char* strVariable("CUserViewFrame::OnNotifyNewData START");
const char* strValue("6");
CUtility::LogDebugInfo( strVariable, strValue);

WRITE_LOG_FUNCTION_ENTRY("LRESULT CUserViewFrame::OnNotifyNewData
(WPARAM wParam, LPARAM lParam)")

PInstData pInstData = (PInstData)wParam;
if (!pInstData) return 0;

CString csText;
char buffer[255];
LVFINDINFO info;
int iIndex = 0;

PSystemSetting pSystemSetting = CSystemSetting::GetObject();

info.flags = LVFI_WRAP|LVFI_STRING;
std::vector<CMarketData>::const_iterator iter;
std::vector<CParticipant>::const_iterator iterpart;

const std::vector<CMarketData& userListBid =
pInstData->GetMarketDataBid();
for (iter = userListBid.begin(); iter != userListBid.end(); iter++)
{
const std::vector<CParticipant& participants =
iter->GetParticipants();
for (iterpart = participants.begin(); iterpart != participants.end();
iterpart++)
{
if (iterpart->GetSize() 0.0 && iter->GetPrice() 0.0)
{
memset(&buffer, 0, sizeof(buffer));
if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255
continue;
//sprintf(buffer, "%s", iterpart->GetUserName()/*.c_str()*/);
info.psz = iterpart->GetUserName();
iIndex = m_ctrlUserListCtrl.FindItem(&info);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListCtrl.GetItemCount();

if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255
continue;
//csText.Format(TEXT("%s"), iterpart->GetUserName()/*.c_str()
csText = iterpart->GetUserName(); //Sanjeev 012407
int size = iterpart->GetUserName().GetLength();
char bufsize[20];
memset(&bufsize, 0, sizeof(bufsize));
_itoa(size,bufsize,10);
CUtility::LogDebugInfo( "OnNotifyNewData - BID UserName", bufsize);
m_ctrlUserListCtrl.InsertItem(LVIF_TEXT|LVIF_STATE , iIndex, csText,
0, LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLength() + 1];
strcpy(pchText, (LPCTSTR)csText);
m_ctrlUserListCtrl.SetItemData(iIndex, (DWORD)pchText);
}
if (sizeof(pInstData->GetInstName()/*.c_str()*/) 255)
continue;
//csText.Format(TEXT("%s"),
pInstData->GetInstName()/*.c_str()*/); csText =
pInstData->GetInstName();
m_ctrlUserListCtrl.SetItemText(iIndex,
eUserViewListColumn::BID_INST, csText);

memset(&buffer, 0, sizeof(buffer));
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalSize());
csText.Format(buffer, iterpart->GetSize());
m_ctrlUserListCtrl.SetItemText(iIndex,
eUserViewListColumn::BID_SIZE, csText);

memset(&buffer, 0, sizeof(buffer));
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalPrice());
csText.Format(buffer, iter->GetPrice());
m_ctrlUserListCtrl.SetItemText(iIndex,

eUserViewListColumn::BID_PRICE, csText);

if (sizeof(iterpart->GetTimestamp().c_str()) 255)
continue;
csText.Format("%s", iterpart->GetTimestamp().c_str());
m_ctrlUserListCtrl.SetItemText(iIndex,
eUserViewListColumn::BID_TIME, csText);
}
}
}

const std::vector<CMarketData& userListAsk =
pInstData->GetMarketDataAsk();
for (iter = userListAsk.begin(); iter != userListAsk.end(); iter++)
{
const std::vector<CParticipant& participants =
iter->GetParticipants();
for (iterpart = participants.begin(); iterpart != participants.end();
iterpart++)
{
if (iterpart->GetSize() 0.0 && iter->GetPrice() 0.0)
{
memset(&buffer, 0, sizeof(buffer));
if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255)
continue;
//sprintf(buffer, "%s", iterpart->GetUserName()/*.c_str()*/);
int size = iterpart->GetUserName().GetLength();
char bufsize[20];
memset(&bufsize, 0, sizeof(bufsize));
_itoa(size,bufsize,10);
CUtility::LogDebugInfo( "OnNotifyNewData - ASK UserName", bufsize);
info.psz = iterpart->GetUserName();
iIndex = m_ctrlUserListCtrl.FindItem(&info);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListCtrl.GetItemCount();
if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255)
continue;
//csText.Format(TEXT("%s"), iterpart->GetUserName()/*.c_str()*/);
csText = iterpart->GetUserName();
m_ctrlUserListCtrl.InsertItem(LVIF_TEXT|LVIF_STATE , iIndex, csText,
0, LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLength() + 1];
strcpy(pchText, (LPCTSTR)csText);
m_ctrlUserListCtrl.SetItemData(iIndex, (DWORD)pchText);
}
if (sizeof(pInstData->GetInstName()/*.c_str()*/) 255)
continue;
//csText.Format(TEXT("%s"), pInstData->GetInstName().c_str());
csText = pInstData->GetInstName();
m_ctrlUserListCtrl.SetItemText(iIndex,

eUserViewListColumn::ASK_INST, csText);

memset(&buffer, 0, sizeof(buffer));
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalSize());
csText.Format(buffer, iterpart->GetSize());
m_ctrlUserListCtrl.SetItemText(iIndex,

eUserViewListColumn::ASK_SIZE, csText);

memset(&buffer, 0, sizeof(buffer));
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalPrice());
csText.Format(buffer, iter->GetPrice());
m_ctrlUserListCtrl.SetItemText(iIndex,

eUserViewListColumn::ASK_PRICE, csText);

if (sizeof(iterpart->GetTimestamp().c_str()) 255)
continue;
csText.Format("%s", iterpart->GetTimestamp().c_str());
m_ctrlUserListCtrl.SetItemText(iIndex,

eUserViewListColumn::ASK_TIME, csText);
}
}
}

VERIFY(m_ctrlUserListCtrl.SortItems( CompareFunction, r

einterpret_cast<DWORD>(&m_ctrlUserListCtrl)));

WRITE_LOG_FUNCTION_EXIT("LRESULT
CUserViewFrame::OnNotifyNewData (WPARAM wParam,
PARAM
lParam)")

const char* strVariable1("CUserViewFrame::OnNotifyNewData END");
CUtility::LogDebugInfo( strVariable1, strValue);

return 0;
}
Is there any chance the sprintf or CString Format function is creating
this problem.

I have spent lot of time it undertsanding this bug with no success. Any
help would be greatly appreciated.

Regards,
Sandy

Jan 24 '07 #1
1 2080
Sandy a écrit :
[snip]
if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255
continue;
I guess iterpart->GetUserName() returns a kind of string (CString?)
Then you have to use the .size() method and not sizeof (which returns
the size of the class).

//sprintf(buffer, "%s", iterpart->GetUserName()/*.c_str()*/);
Instead of using sprintf, you can use sstream;
ostringstream os;
os<<iterpart->GetUserName();
....
os.str(); //get resulting string

If you prefer to use sprintf, use the c_str() method (that you commented
out).
>
if (sizeof(iterpart->GetUserName()/*.c_str()*/) 255
continue;
Idem and so on
[snip]
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalSize());
csText.Format(buffer, iterpart->GetSize());
If Format accepts classical format, you can 'simply' use * to specify
the width:
csText.Format(buffer,"%.*f",
pSystemSetting->GetDecimalSize(),
iterpart->GetSize());

I expect your sprintf implementation works with it .

Michael
Jan 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeff | last post by:
I've been working on an app that has the usual Application.Run(new MyForm()) call in the static void Main (). I can run this executable when I run it on my development machine, but when I install...
1
by: Darren Jensen | last post by:
Hi, I have a machine which is running Windows Server 2003, IIS and .NET V1.1. I have been using this machine very well for about 6 months now for running ASP.NET on IIS and the occasional .NET...
9
by: hhh12347 | last post by:
FolderBrowserDialog crashes on my Windows 2000 computer. Here is a C# test program: using System; using System.Windows.Forms; public class TestForm : Form { FolderBrowserDialog...
7
by: abcd | last post by:
I have asp.net application which was tested and developed on asp.net 1.1. WIll my application work on asp.net 2.0 also. Can I say asp.net 2.0 is supported automatically for the applications which...
7
by: Abubakar | last post by:
Hi. I got the following error while running an exe made in visual studio 2k5c++ (all native unmanaged) --------------------------- Microsoft Visual C++ Debug Library...
1
by: Jeemo | last post by:
I've been tearing my hair out on this one. This effin' database keeps crashing on me while I'm doing query-related operations. System info: Access 2003 SP2 with all the latest updates on an XP...
6
by: Jeemo | last post by:
I've been tearing my hair out on this one. This effin' database keeps crashing on me while I'm doing query-related operations. System info: Access 2003 SP2 with all the latest updates on an XP...
0
by: Sandy | last post by:
HI All, I have created a MFC exe using VC++ .NET 2003 on Windows XP Prof service pack 2 and it works properly on my machine, but when I run the same exe on a different machine (Windows XP Prof...
4
by: billsahiker | last post by:
Why is my application crashing on a windows 98 machine? It runs fine on the development machine with xp pro. I installed framework 2, with dotnetfx.exe, and windows installer 2 on the windows 98...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.