|
I do not want to run it in debugger, I want it to run at customer's computer and send me the correct crash report (currently working for unhandled non-CException exceptions)
|
|
|
|
|
OK - here's a thought...
I'm presuming you're using CArray code in afxtempl.h. This calls AfxThrowInvalidArgException() to throw the exception you're seeing.
Why not use a #define to change what AfxThrowInvalidArgException means?
If we use this articles[^] code to provide a stackwalker, you could do something like this #define (put it in your code BEFORE you #include afxtempl.h)
#define AfxThrowInvalidArgException() { StackWalker sw; sw.ShowCallstack(); AfxThrowInvalidArgException(); }
You'd need to add something to change how the stack trace is displayed, and also distribute dbghelp.dll with your app, but I think it could help you?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for idea, I was now going to create some CArrayEx template which would derive from carray and add AfxThrowInvalidArgException() as member function which would just throw -1 or something. Macro approach is faster so I'm going to give it a try.
Still it looks to me weird why rethrowed CException just disappeared and didn't crash the app. When I was tracing my (re)throw in debugger, it wanted to go to some throw.cpp file but didn't have a source.
|
|
|
|
|
#define approach does not work. It is ignored and I'm still getting old exception. I'm afraid I'll have to create my own template for CArray or redesign all the code to std::vector
|
|
|
|
|
rrrado wrote: redesign all the code to std::vector
Not such a bad idea - I gave up on CArray over 10 years ago, when I was using VC5 (which was even shonkier with templates than VC6).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
If I'd thought a bit more, I'd have realised that could never work for various reasons. However, this suggestion does let you intercept AfxThrowInvalidArgException:
- BEFORE you #include any MFC headers (so put this in your stdafx.h), add this:
#define AfxThrowInvalidArgException MyThrowInvalidArgException - Now add this code at the end of one of your .cpp files, changing the body to suit what you want to do
void __stdcall MyThrowInvalidArgException()
{
#undef AfxThrowInvalidArgException
OutputDebugString(_T("WHOOPS"));
void __declspec(noreturn) AFXAPI AfxThrowInvalidArgException();
AfxThrowInvalidArgException();
}
I've tried this under VS2008 with a simple MFC app and MyThrowInvalidArgException was called when I executed this code:
CArray<int, int> arr;
arr.GetAt(100);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you very much for your time. I've made it to work with macro, but modified, I hope it will help me.
|
|
|
|
|
Hi iam working on LotusNotes, plz let me know how to get created date from a Document,. i can able to retrieve PostedDate by using. date.GetDateSent(), plz let me know which function is helpful for me to retrieve CreatedDate.
|
|
|
|
|
GetCreated(); function may be help full to get the created date for a message
|
|
|
|
|
I have a Problem when coverting System time to file time and assigning it to a Mail in Mapi, My problem is i dont have control on setting AM,Pm of a time and which is adding 5:30 hrs extra to a time how to control AM and PM and assign a correct time i need the conversion compulsory,
Any help is highly appreciated
SYSTEMTIME systemtime;
FILETIME filetime;
systemtime.wYear=2009;
systemtime.wMonth=3;
systemtime.wDay=1;
systemtime.wDayOfWeek=5;
systemtime.wHour=5;
systemtime.wMinute=30;
systemtime.wSecond=17;
systemtime.wMilliseconds=39;
SystemTimeToFileTime(&systemtime,&filetime);
prop.ulPropTag = PR_CREATION_TIME;
prop.Value.ft=filetime;
pNewMessage->SetProps(1,&prop,NULL);
|
|
|
|
|
Pardhu_M wrote: My problem is i dont have control on setting AM,Pm of a time
Ummm - you've heard of the 24 hour clock[^]? AM times in SYSTEMTIME have hour =0-11, PM times have hour=12-23. So 5PM is hour 17.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Actually my problem is when i assign values to system time and convert it into file time it is adding 5.30 GMT which i dont need it i need actual time which i assigned to system time.
|
|
|
|
|
What timezone are you in? Is it possibly India, which is 5 hours 30 minutes ahead of GMT?
That's where the delta's coming in, I would suggest. You need to learn the difference between UTC times (which is how FILETIMEs are interpreted) and local times. There are functions that can help you convert between local and UTC times, but FILETIMEs are always interpreted as UTC.
[edit]The reason you see the conversion to FILETIME as adding 5.5 hours is that when you see the presentation of the filetime, it's through a function that applies a timezone offset (GMT -> India), adding 5.5 hours.
What you need is to use TzSpecificLocalTimeToSystemTime[^] to convert your original, local SYSTEMTIME to a UTC SYSTEMTIME. Then use SystemTimeToFileTime to convert the UTC SYSTEMTIME to a FILETIME.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Buddy I got It........
|
|
|
|
|
Hi every one
There is one application on my system that it’s opened my Clipboard and Empty it. but didn’t close Clipboard until closing the application .
I want attach to application by my application and send closeclipboard api to it.
Its my code but don’t work . how can i empty clipboard when it has been opened by another program?
Plz help me.
CWnd *pWnd=new CWnd();
BOOL bo,be,bc;
pWnd= GetOpenClipboardWindow();
pWnd=FindWindow("Application class name","Application title");
if(pWnd)
{
bo=pWnd->OpenClipboard();
be=EmptyClipboard();
bc=CloseClipboard();
}
modified on Saturday, July 11, 2009 8:01 AM
|
|
|
|
|
How to Get the installer path of Internet Explorer using C++
|
|
|
|
|
Why do you want to do that? The various reasons I can think of for needing the path to Internet Explorer could well be satisfied using a different method that doesn't need the path.
Aside from that, you could a) look at the Internet Explorer shortcut in the Start Menu (if there is one), or b) Look in the registry @ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths.
But please answer the first question. There's usually a better way.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thx stuart..but i need programatically plz help
|
|
|
|
|
Ummmm - you realise that you can do those things programmatically and that is precisely what I meant you to do....
But as I said - why do you need the path to Internet Explorer?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
If it's the default browser, you could use FindExecutable() . There's also HKCR\http\shell\open\command in the registry.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
How to populate custom data in VSFlexGRID.
Any idea how to set custom data source to flex grid using C++/COM programing .
Any othe way efficient way for dynamic data population in VSFlexgrid.
|
|
|
|
|
You may possibly get help at their community[^]. This forum is for specific questions related to C/C++/MFC.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have a BYTE array that I'm trying to split into parts and put the parts in a vector:
#include <iostream>
#include <vector>
#include <algorithm>
#include <malloc.h>
#ifndef LPBYTE
typedef unsigned char * LPBYTE
#endif
void split(vector<LPBYTE>& vect, const LPBYTE& lpbData) {
LPBYTE start = lpbData;
LPBYTE end = lpbData + (size_t) 2;
size_t len = distance(start, end);
LPBYTE lpbPart = new BYTE[len];
memcpy(lpbPart, start, len);
vect.push_back( lpbPart );
}
int main() {
LPBYTE data = {'a', 'b', 'c', 12, 22, 'Q'};
vector<LPBYTE> parts;
split(parts, data);
for (vector<LPBYTE>::iterator vIT = parts.begin(); vIT != parts.end(); vIT++)
cout << (char *) *vIT << "\n";
parts.clear();
} The problem with the heap version is that it leaks.
But if I use the stack version, or if I were to delete lpbPart inside split() (after adding it to the vector), a bunch of garbage is output 'cause the address is no longer valid.
I could iterate through the vector when I'm done with it, delete -ing each element... but I was told recently that that is a bad programming practice.
I am leaning towards deriving a class from vector and delete -ing the elements in the destructor, but I thought I'd run it by you guys first and see if there was a better way.
OR if there is a way to make a sub-array of an array, where the sub-array points to an address within the array but has a length shorter than the distance from the address within the source array to its end. This way would avoid the stack and the heap and the addresses would be valid so long as the source LPBYTE data was valid. It isn't good code, but to better explain what I mean:
LPBYTE data = {'a', 'b', 'c', 12, 22, 'Q'};
BYTE sub[2];
&sub = data + 2;
As always, any help ya'll can give is greatly appreciated!
MZR
|
|
|
|
|
If you have used new[], you have to use delete[]. That is not bad programming practice. Rather, I would say that using new[] in the first place is bad programming practice.
Are you trying to create several smaller BYTE arrays from one large BYTE array?
If so, I would recommend creating a vector<vector<BYTE>> sub .
You could then assign values to sub as follows.
vector<BYTE> small;
small.assign(data.begin(), data.begin() + 2);
sub.push_back(small);
small.assign(data.begin() + 3, data.begin() + 5);
sub.push_back(small);
Or you can use Boost.MultiArray[^].
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Mike the Red wrote: OR if there is a way to make a sub-array of an array, where the sub-array points to an address within the array but has a length shorter than the distance from the address within the source array to its end. This way would avoid the stack and the heap and the addresses would be valid so long as the source LPBYTE data was valid. It isn't good code, but to better explain what I mean:
Arrays==pointers. The size of an array is not (repeat NOT) stored with the pointer. So, you could store pointers into the original array in the vector, but you'd need to store some way of knowing what the end ot the part was. You could do it like this:
void split(vector<std::pair<LPBYTE, LPBYTE> >& vect, const LPBYTE& lpbData)
{
LPBYTE start = lpbData;
LPBYTE end = lpbData + (size_t) 2;
vect.push_back(std::make_pair(start, end));
}
and you'd have to declare parts as
vector<std::pair<LPBYTE, LPBYTE> > parts;
This concept is known as an iterator range and is supported within some[^] libraries[^].
The iterator range is what is known as a half-open range. What this means is that the start of the range is part of the range, but the end of the range actually points to the first element AFTER the range. Sounds odd? Well, it's the way that all the STL iterators and algorithms work, so these ranges have compatibility with those, which is a good thing, IMO.
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|