|
If it's crashing after the opening brackets, I'd check any global variables you may have, any constructors that may be failing. You can put breakpoints inside the constructors as well as any statically initialized variables.
Joel Lucsy
|
|
|
|
|
Hi, I am trying to write files on a CD RW disk formatted under the Apaptec Direct CD program. If am getting a "File not found" error on return from CFile::Open() - the code (which works on a hard disk directory) is as follows:-
if( !DestFile.Open( sDest, CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyWrite, &e ) )
{
#ifdef _DEBUG
CString sMsg;
sMsg.Format("Destination file %s could not be opened - error code = ",sDest);
afxDump << sMsg << e.m_cause << "\n";
if(e.m_cause == CFileException::sharingViolation)
afxDump << "ERROR: Sharing violation\n";
if(e.m_cause == CFileException::fileNotFound )
afxDump << "ERROR: File not found\n";
#endif
}
Do I have to do something special with CD RW's ???
Doug
|
|
|
|
|
Hi!
I try to build an Desktop switcher - like the one in KDE
<br />
CWnd *pWnd = CWnd::FindWindow("Progman", "Program Manager"); <br />
<br />
if(!pWnd)<br />
return;<br />
<br />
CWnd* pChild = pWnd->GetWindow(GW_CHILD);<br />
HWND hWnd;<br />
pChild->GetDlgItem(0x1, &hWnd);<br />
ASSERT(IsWindow(hWnd));<br />
CWnd* pCtrl = (CWnd*)CWnd::FromHandle(hWnd);<br />
((CListCtrl*)pCtrl)->DeleteAllItems();<br />
<br />
LPITEMIDLIST id;<br />
static char path[1024];<br />
SHGetSpecialFolderLocation(hWnd,CSIDL_DESKTOPDIRECTORY ,&id);<br />
SHGetPathFromIDList(id,path);<br />
<br />
CString strDesk;<br />
strDesk = _T(path);<br />
strDesk += "\\*.*";<br />
CFileFind finder;<br />
BOOL bWorking = finder.FindFile(strDesk);<br />
<br />
while (bWorking) {<br />
bWorking = finder.FindNextFile();<br />
((CListCtrl*)pCtrl)->InsertItem(0,(LPCTSTR)finder.GetFileName(),0); <br />
}<br />
The strange think is, that sometimes i can Insert Items without any problem. But sometimes i got an access error. DeleteAllItems works well, but InsertItem causes access errors.
What have i done wrong?
thx cya
sorry for my bad English
|
|
|
|
|
Dear All,
I am developing an application in MFC VC++ Version 6.0 for Windows 2000. My application sometimes throws following error just before starting (it come some times,, not always)
.........................
Application Error:
The instruction at "0x102404fa" referenced memory at "0x5b4e4f49". The memory couldnot be "read"
............................
Can anybody tell me what can be the reason behind this ??
Feel free to ask any further queries in this regards,
Thanks
Rohit Dhamija
|
|
|
|
|
Looks like a stack corruption. You've probably run off the end of a buffer somewhere.
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi Taka,
Thanks for replying.
Can you tell me any way to resolve this bug ? Because it is not coming always, only some times..
Stack corruption ???
Can you tell me possible reasons for stack corruptions..
Rohit
|
|
|
|
|
Buffer overruns are the most common cause. Look at the following code:
char* p = "hello world!" ;
char buf[5] ;
strcpy( buf , p ) ;
The string you are copying is too big for the buffer and strcpy() will just blindly copy past the end of the buffer, blowing away anything that was there.
The other possibility is you are writing through an invalid pointer that is occasionally pointing into the stack.
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Thanks takka,
I think this will be of great help in locating possible cause of error.
But my applications is very large and will take long time to find such silly mistake. Can we get some help from the error itself ??? The error stated that
.........................
Application Error:
The instruction at "0x102404fa" referenced memory at "0x5b4e4f49". The memory couldnot be "read"
............................
How can we take the help of this error to find exact location of the culprit .
Rohit
|
|
|
|
|
Rohit Divas wrote:
How can we take the help of this error to find exact location of the culprit
You can't. If you look at the memory address, you'll see that it looks like string data. You probably put some string data onto the stack and the CPU has tried to interpret it as an instruction address. The #1 cause of this is the code snippet I gave before.
"Sucks less" isn't progress - Kent Beck [^]
Awasu 1.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
|
Have you tried running a debug build? (I assume you have, but just wanted to confirm).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
YES i have tried, and I changed some code. Now I will again run a debug build .
|
|
|
|
|
I am a very new person to programming in general. does anyone know how make a program that will let me send messages from my comp at school to the others around me similar to the dos command net send)
:P
|
|
|
|
|
You could always wrap "net send" in your own application by using ShellExecute().
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
Whats shellexecute() iv'e only been programing 2 weeks?
|
|
|
|
|
Check it out in MSDN. If you don't have it installed, check this[^] out.
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
I want get a associated icon from a file system (for example c:\test.doc") using SHGetFileInfo function and save it in a file (for ex "C:\myicon.ico").
But GlobalSize and GlobalLock returns 0 (invalid value!!!).
Please give me a good idea!
Tnk you
/******MY CODE*****/
CString nomefile = "c:\\test.doc";
HICON hGen32Icon;
HIMAGELIST hSysImageList;
SHFILEINFO shfi;
int fh;
UINT uiSize;
DWORD dwSize;
LPVOID lpGMem;
OFSTRUCT of;
hSysImageList = (HIMAGELIST)SHGetFileInfo
(nomefile,
0,
&shfi,
sizeof (SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
hGen32Icon = ImageList_GetIcon (hSysImageList,
shfi.iIcon,
ILD_NORMAL);
dwSize = GlobalSize(hIcon); /*Don't work*/
lpGMem = GlobalLock(hIcon); /*Don't work*/
fh = OpenFile ("c:\\myicon.ico", &of, OF_WRITE | OF_CREATE);
if (fh == -1) // If NOT opened successfully.
{
MessageBox("Unable to create file", NULL, MB_OK );
}
uiSize = _lwrite(fh, (LPSTR)lpGMem, (UINT)dwSize);
_lclose(fh);
|
|
|
|
|
|
Hi,
Currently, I need to do read/write on disk sector under Win2000/XP. I found out that the statement below is only valid for administrator.
hDisk=CreateFile("\\\\.\\C:", GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, NULL, NULL);
...
For non-admin user, the above statement will always return hDisk=INVALID_HANDLE_VALUE. My question is how can we solve this problem? Can we assign access right or privilege in our program in order to access disk sector? or do we need to develop VXD to solve this problem?
Hope that some of you can give me some hints. Thanks in advance!
Best Regards,
K Wan
|
|
|
|
|
Yes my friend
As far as my Knowledge
u will neet a service to do the above work
and not a VXD cause VXD is required on 9X M/C
and No such funda like aadministrator in 9X M/C
ok i hope this solev ur prob..
Thanx
TAKE CARE
|
|
|
|
|
Thanks for pointed out my mistake and confusion.
Basically, what does the service do in this problem? Can the service use 'CreateFile' to access the disk sector for non-admin user?
Since the security context for file system root (eg: 'c:','d:') will be lost every time we restart the computer, how do we solve this problem?
More hints and guides for me?
Thanks!
|
|
|
|
|
whenever i add items from a treelist to a list box, the items are jumbled up and not in the order in which i was adding one by one. i use the following code :
HTREEITEM hTreeItem1;
HTREEITEM hTreeItem2;
HTREEITEM hTreeItem3;
hTreeItem1 = m_tree.GetSelectedItem ();
hTreeItem2 = m_tree.GetParentItem(hTreeItem1);
hTreeItem3 = m_tree.GetParentItem (hTreeItem2);
if(hTreeItem3 != NULL){
m_strlist_process = m_tree.GetItemText(hTreeItem3)+m_tree.GetItemText(hTreeItem2)+m_tree.GetItemText(hTreeItem1);
}
else
m_strlist_process = m_tree.GetItemText(hTreeItem2)+m_tree.GetItemText(hTreeItem1);
m_list.AddString(m_strlist_process);
UpdateData(FALSE);
btw, as i wan to display the 3 items, how to have spcaing between them so that they wun appear all join together in a line? thanx
|
|
|
|
|
Your list box probably has the sort property set by default. Turn it off et voilá (I hope ).
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|
|
thanx! i disabled it and it works now, but the prob left is the items are displayed together in a line without spacing. i type
m_strlist_process = m_tree.GetItemText(hTreeItem2)+" "+m_tree.GetItemText(hTreeItem1);
it din work, any solution?
|
|
|
|
|
If m_strlist_process is a CString, it should work the way you wrote it with " ". Otherwise I think you should get compilation errors.
Cheers,
Fredrik
"Felix qui potuit rerum cognoscere causas."
|
|
|
|