|
Exceptions, use them. They're great. They make your code a lot cleaner by:
1. Not requiring you to check for errors after every function call.
2. Grouping your error checking/handling code in the places where it makes sense.
3. Allowing your methods to return other more relevant information, instead of having to worry about always returning error codes.
4. Allowing you to receive not just an error code, but a descriptive message to go along with it, as well as whatever other information you want to provide.
Look at newer languages such as Java and C# and they all make extensive use of exception handling. It's the way to go.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Does anyone know how to get the headers the server sent back with a page in the WebBrowser control?
|
|
|
|
|
I want my application to be opened once at the time. 2 different processes of my application cannot be created. If my appliaction is run and I want to run it again the previously created application should be opened.
I am looking for some tutorials or a piee of code
Please help
|
|
|
|
|
There are several article about that on this site !
Take a look at the Thread, Processes & IPC section !
|
|
|
|
|
One solution is mutex.
Kuphryn
|
|
|
|
|
Look for Singleton applications...
|
|
|
|
|
I have a com dll written in C++ which is used in asp applications. The dll contains only one com object. There are static (global to the process) data objects within this dll. Obviously, I only want to initialize these static objects when the dll is first loaded.
However, IIS seems to be reloading my dll everytime the com object is created and used in an asp page.
|
|
|
|
|
Load it inside global.asa into Application object?
Brian
|
|
|
|
|
Sorry, I am using this C++ com dll in asp projects, not ASP.NET projects.
|
|
|
|
|
I have a question.
This is the way I connect to the file through http
CHttpFile *pHttpFile = (CHttpFile *)InternetSession.OpenURL(LPTHD->from,INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD);
Everything works fine, but in case the url does not exist I obtain the pointer to the html error page. How to check that the url hasn't been reached?
Please help
|
|
|
|
|
Check HTTP response code, must be 200 (200 OK) or 2xx I think
rrrado
|
|
|
|
|
I know that but i don't know hot to get this error code
|
|
|
|
|
Check this function, this will do that :
CHttpFile::QueryInfoStatusCode
rrrado
|
|
|
|
|
Hi all!
Help me please. I need to show preview info in the left of explorer (like we can see preview of bmp, jpg, html etc.). How can I do this? May be someone can send me expample? I`ll be appreciate for any help.
With best regards,
Yura.
|
|
|
|
|
I have noticed while trying to compile the MySQL++ library and from the errors returned that:
the reverse_iterator class has changed. According to the Microsoft documentation there has been a change in the STL library.
I was wondering if this change is limited to the Microsoft version of the STL or is it a change in the ANSI C++ STL?
|
|
|
|
|
FranzKlein wrote:
I was wondering if this change is limited to the Microsoft version of the STL or is it a change in the ANSI C++ STL?
I doubt there has been a change in ANSI C++ STL. Microsoft STL that ships with VC 7.0 is more compliant with the standard.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
FranzKlein wrote:
the reverse_iterator class has changed
Yes, this one has hit me too some times ago. Microsoft made the change to make it ANSI compliant.
|
|
|
|
|
Hi all,
I'm still working on my switch statement program (from previous post)thanks to Joaquin my loop is working but for some reason my switch statements are not being activiated.
I've included a portion of my code, the switch statements continue for each letter a state begins with (d,f,g,h,i,k,etc)
Thanks,
Aaron
<br />
<br />
#include <iostream><br />
#include <fstream><br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
ifstream inAbrev("state abs.txt");
ofstream outState("states with abvs.txt");
char firstLetter,<br />
secondLetter;<br />
<br />
inAbrev >> firstLetter >> secondLetter;<br />
cout << firstLetter << secondLetter << endl;
<br />
while(inAbrev)
{<br />
inAbrev >> firstLetter >> secondLetter;<br />
cout << firstLetter << secondLetter << endl;<br />
<br />
switch (firstLetter)<br />
{<br />
case 'A' : switch (secondLetter)<br />
{<br />
case 'L' : outState << inAbrev << " is " << "Alabama" << endl;<br />
cout << inAbrev << " is " << "Alabama" << endl;<br />
break;<br />
case 'K' : outState << inAbrev << " is " << "Alaska" << endl;<br />
break;<br />
case 'Z' : outState << inAbrev << " is " << "Arizona" << endl;<br />
break;<br />
case 'R' : outState << inAbrev << " is " << "Arkansas" << endl;<br />
break;<br />
}<br />
case 'C' : switch (secondLetter)<br />
{<br />
case 'A' : outState << inAbrev << " is " << "California" << endl;<br />
break;<br />
case 'O' : outState << inAbrev << " is " << "Colorado" << endl;<br />
break;<br />
case 'T' : outState << inAbrev << " is " << "Connecticut" << endl;<br />
break;<br />
}<br />
arrrgh
|
|
|
|
|
set the breakpoint on "switch (firstLetter)" line and check the value of firstLetter and secondLetter variables to see what values exactly are in them.
|
|
|
|
|
It appears as if nothing is happening because all of your output statements (cout and outState) in your switch statement are wrong.
Your doing this:
outState << inAbrev << " is " << "California" << endl;<br />
cout << inAbrev << " is " << "Alabama" << endl;
What this is doing is trying to output the input filestream which, of course, will output nothing.
If I read your homework right, you should be doing something like this:
outState << firstLetter << secondLetter << " is Alabama" << endl;
RageInTheMachine9532
|
|
|
|
|
Yep RageInTheMachine is right.
none
|
|
|
|
|
I have recently written a Service that parses a large XML file using MSXML, breaks the xml down in to fragments, and then calls a SQL Server stored procedure to process the xml fragment. As each call to the stored procedure is made memory is leaked. I have not been able to find any information concering this particular problem. It also appears that the MSXML objects are also leaking memory. The code fragment that follows is where the leak occurs. All pointer are SmartPointers and no dynamic allocation occurs in my code. Anybody have any ideas?
IXMLDOMNodeListPtr LogEntries = pXMLDocRoot->childNodes;
IXMLDOMElementPtr LogEntry = NULL;
for( int i = 0; i < LogEntries->length; ++i )
{
LogEntry = LogEntries->item[i];
if(LogEntry->nodeType == NODE_ELEMENT )
{
CString nodeName = (TCHAR*) LogEntry->nodeName;
CString spName;
spName.Format(_T("sp_%s"),nodeName);
CString xml = (TCHAR*)LogEntry->xml;
// execute this data
if (S_OK != m_AdoCmd.Execute_StoredProc(spName, xml))
{
CString errorMsg;
errorMsg.Format("Failed to execute stored procedure %s: error: %s", spName, m_AdoCmd.m_errorStr);
LogErrorMsg("ProcessXML: " + errorMsg);
return false;
}
}
LogEntry.Release();
}
LogEntries->reset();
Butch
|
|
|
|
|
I have to do this for Windows 95/98/Me/200/NT/XP:
I have the ID of a process(obtained with Process32First/Next) and I want to get the full path of the executable hwo started that process. In PROCESSENTRY32 the member szExeFile gives me only the name of the file but not the full path...
Thank you!
Best regards,
radu.
|
|
|
|
|
One solution is EnumProcessModules().
OpenProcess()
EnumProcessModules()
GetModuleFileNameEx()
Kuphryn
|
|
|
|
|
That's what MSDN says:
Windows NT/2000/XP: Included in Windows NT 4.0 and later.
Windows 95/98/Me: Unsupported.
So it's not a solution for 95/98/Me...
|
|
|
|