|
Thanks for the help. I tried it out, but if gives me the same GUID back again I put in?!
For your question, I use
itemIDList = SHBrowseForFolder(&browseInfo);
...do some checks and then
SHGetPathFromIDList(itemIDList, szPathBuffer);
And at this point I've got that GUID in szPathBuffer. I found so many samples, everyone does it that way, but I already tested on 2 win2k machines and it doesn't work. (Except I update to IE6, but this is currently not an option).
Maybe something is wrong with my browseinfo structure? I did nothing special, maybe some flags are needed I didn't set?
Ingmar
|
|
|
|
|
Then you've got a GUID to a virtual folder that does not have a physical location for it.
PeterRitchie.com
|
|
|
|
|
I tested some things, and it seems the problem isn't SHBrowseForFolder itself. But it's more strange: A simple BrowseForFolder-application works well on 2k, but my real application doesn't! I did try and error and I found out, that I get a good path, when I run SHBroswForFolder before I open a database via ODBC (CDatabase) ?!?!
Don't have a good idea now, but it has definitly to do with the DB-Open. Maybe it's a bug? This works great on XP or better on any machine with IE>5.
Ingmar
|
|
|
|
|
It is my understanding the using the following line of code is bad pratice.
delete this;
Is there ever a good reason to use this construct?
Thanks
|
|
|
|
|
Like anything else, if it is used properly it has its uses, but used improperly it can be disatrous. I use it for classes that are to be self deleting, and always make sure it is the very last command the class executes.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
It's how COM object lifetime is managed. Last one to call Release(), essentially tells the object to delete itself. For instance:
ULONG Release(void)
{
ULONG lResult = InterlockedDecrement(&m_dwRef);
if (lResult == 0) delete this;
return lResult;
}
|
|
|
|
|
Okay so COM makes use of it and also with self deleting classes.
I understand the COM aspect but what is a self deleting class?
Let me clarify the question a little. Is there a general rule? When would you use delete this?
Thanks
|
|
|
|
|
smesser wrote:
what is a self deleting class?
A class that deletes itself. Examples are CFrameWnd and CWinThread (when m_bAutoDelete is TRUE).
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Yeah, but that is framework stuff. When as a programmer have you used:
delete this;
Steve
|
|
|
|
|
|
with MFC, it's used to delete a modeless dialog.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have been programming with c++ since the Cfront "compiler" came out of ATT. I have never found a circumstance where delete this seemed like a correct solution. My impresssion is that it is an artifact of bad design. The fact that the MFC and COM implementation require it is not a surprise Along the same line, throwing an exception via a pointer is equally dangerous in my book!
|
|
|
|
|
Brian R wrote:
it is an artifact of bad design
It is a tool that makes it easier to use and then dispose of one time objects without having to keep track of the pointers and memory yourself. Using it is a design decision, not "bad design". Abusing it is bad design, but then abusing anything is.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
Using it is a design decision, not "bad design". Abusing it is bad design, but then abusing anything is
I am in 100% agreement with you. Even the infamous 'goto' is cursed as a bad design paradigm. But circumstances govern their use in a few specialized cases. After all 'delete this' has certainly come to my rescue when I had to monitor the lifetime of an object using a reference counter similar to the COM classes. I seem a fair use of 'delete this' in such case. Also there are so many things in C++ that if abused screw up the program, better curse programming skill than curse a language
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
Mayur Mahajan wrote:
But circumstances govern their use in a few specialized cases.
A paper put together in 1966 by BÖhm, Corrado, and Guiseppe proved theoretically that the GOTO statement was unnecessary; Dijkstra considered it harmful; and Knuth said it might be useful in some circumstances.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, the main point here is:
We have razor sharp tools in the kit. If you can handle them, use it...else they'll hurt you bad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
thanks all I now have a better understanding of this topic.
|
|
|
|
|
You can use it in exception classes, which may be created on the stack or dynamically on the heap. When you call some Delete function, you can delete this if the object is created on the heap.
I also got the blogging virus..[^]
|
|
|
|
|
Hi
Can somebody please guide me how to wite an ISR in visual c++ 6.0. I need to handle some interrupts
Thanks
Leelanga
|
|
|
|
|
To my knowledge, ISRs haven't been used since DOS and 16-bit Windows. What exactly is it that you are trying to do?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I don't think that windows is polling for mouse, keyboard or any other hardware events...
But if you mean that the programmer has to use ISR's, you can't. I don't know since what OS version, but at least since Win2K those instuctions are "priviliged", meaning that they can only be executed in supervisor mode. Thats where device drivers come in.
I also got the blogging virus..[^]
|
|
|
|
|
Having never delved into a device driver project before, this is unfamilar territory for me. Thanks for the heads-up.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You're welcome!
To be honest, I didn't work on a device driver project either, but I've worked on small embedded systems. Also I had a subject in college recently that focused on hardware and Windows.
I also got the blogging virus..[^]
|
|
|
|
|
Actualy I've developed a small h/w device to control telephone line. I use the paralell port to interface the device. So i need to hadle interrupts generated by it
Thanks a lot
Leelanga
|
|
|
|
|