473,385 Members | 1,356 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,385 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 2087
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.