|
Yes, but it's not in a return statement, like your first example, and therefore is not deleted because it is still in scope during the call.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
That creates a new _variant_t object and returns its address. However that is a temporary object, and gets destroyed at the end of whatever statement it's in, so you can't use that as a function return value, because the pointer will be invalid back in the calling code (it won't point at a valid object).
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
I see your website, that is nice !!!
By the way, It is all the source code:
long lArray = 0;
COleSafeArray ole_array;
ole_array.CreateOneDim(VT_VARIANT, 1);
ole_array.PutElement(&lArray, &(_variant_t("NAME")));
I read MSDN, i must pass void * value to second parameter in PutElement, but in this example he wrote: &(_variant_t("NAME")) !!!
I can't understand
help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
As I said already, that makes a new temporary _variant_t object and takes its address. That address is passed to the PutElement() function. Since by C++ rules, any pointer can be implicitly converted to void*, no cast is needed.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Does anyone know how to throw an exception across threads?
Is this possible at all given the stack unwinding issues? Is there perhaps some other mechanism for interrupting the logic of one thread from another without Waits or SleepEx or other sync functions. Callbacks - from timers etc. - are in the calling thread so they are no good to me.
I need to protect a block of code as follows,
Start timer
-------------
Code Block
normal exit
-------------
Timeout
timeout exit
The try/catch block is ideal but the timers run in their own threads so I don't catch nothing.
Thanks to all!
|
|
|
|
|
AFAIK throwing an exception from a thread will cause the exception to be propogated down the stack of the thread only - if it were to be caught by another thread then the operating being performed by that thread would have to be interrupted etc and it would just be a disaster as well as being unimplentable (practially at least).
A better solution is to return an error value from the thread.
--
Andrew.
|
|
|
|
|
I think you are correct and a thread can't be interrupted. I don't see any great technical difficulty in doing it (that's really what the scheduler does after all) but the system is designed not to do it, so that's that.
I looked at APCs but they only work when the thread is sleeping or waiting so that's no good to me either. I need to have functions (node/action functions for a state machine written by others) running by themselves and being timed out in the state engine which I wrote.
What do you mean "return an error value from the thread"? Do you mean the value in the terminating "return int" or some other mechanism I don't know about. I know you can get the terminating value when a thread exits is this what you mean?
Thanks for your thoughts anyway.
Joe M.
|
|
|
|
|
I think you are correct and a thread can't be interrupted. I don't see any great technical difficulty in doing it...
Yes, it is easy for threads to be suspended. However, to change the path of execution for a thread is unthinkable - I mean, if your program is carrying out a task and half way through writing to a file the control gets shifted to a code handler you've had it.
Yes, I did mena the terminating return int statement.
--
Andrew.
|
|
|
|
|
Anyone know if it's possible to automate the build process? I have about a dozen projects in one workspace, and I want to be able to say "build all" and have it build each individual project in the right order in the right configuration. Possible?
I started to automate with NMAKE and Python, but goddam it would be nice if VC++ did it for me.
J
|
|
|
|
|
Yes, Batch Build.
In the menu look for Build and then Batch Build.
Is esay to use.
Good Luck.
Happy Weekend
Carlos Antollini.
Today is Friday!!!
SShhh Bob!!!
|
|
|
|
|
That doesn't let me customize the order.
J
|
|
|
|
|
To customize the order set the dependencies. Project/Dependencies menu pick.
HTH
Jignesh
|
|
|
|
|
You can change the order with Project/dependencies but I have a secret...
shhh, don't say nothing but sometimes carlos changes the order editing the .dsw file. Is a dangerous practice, but it works. Never change the position of the principal project.
Cheers
Nice Weekend
Carlos Antollini.
Today is Friday!!!!
SSSShhh Bob!!!
|
|
|
|
|
Thanks, but I need a little more flexibility.
What I would love to have is a batch build builder. A dialog like the batch build one that would let me pick the projects and the order, and then save that as, say, the "Debug" build. Then I could create another order for the "Release" build.
I have a workspace with a dozen projects. Some are COM servers that register themselves during the build. I don't want to have a combination of debug and release servers running, so I want to be able to say "build me the debug version of everthing", or "build me the release/releaseMinDependency version of everything".
I started to write a little script that would use nmake or something to do the build, but I was just hoping that something would already exist.
Guess not, but thanks for the suggestions.
J
|
|
|
|
|
|
That's what I needed. I hadn't realized that the macro stuff was VBScript. I thought it was just keystrokes and stuff.
Thanks so much.
J
|
|
|
|
|
You might also want to look at setting dependencies among the projects (Project menu).
If you want to go the command line route, check out "Building a Project from the Command Line" in the MSDN.
VC5 required you to export make files and run nmake on em, but in VC6 you can call msdev directly. Kinda cool.
|
|
|
|
|
You can run MSDEV with the /MAKE switch to have it build projects in a workspace. See the page "Building a Project from the Command Line" in MSDN for the details. You can also run MSDEV /? to see help on the switches.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
I am having trouble with the date and time data types when running my app on a machine in China where the regional settings are different. How do I change the regianl settings to North American style? or is there a better solution?
Please help.
|
|
|
|
|
Depends that you need.
I build Applications that runs in sevreal countrys with the same problem:
For example, In some countrys the people use dd/mm/yyyy but in US the common format is mm/dd/yyyy, I prefer that the people Enter the date, and I get the date, month, and Year. For this I use the COleDateTime class, That permit me make this. The class resolve the problem.
When I try to insert the data into a SQL Server, I use the format that I need. In other words I build the format date, from the variables of day, month and year.
But you can change the regional settingas, but Is not good for the user. If you are interesting in that please contact me.
Carlos Antollini.
today is Friday!!!!
SSShhh bob!!!
|
|
|
|
|
Changing the user's regional settings out from under them is a Very Bad Thing. The solution is to not hard-code your program for a particular time or date format. Use GetTimeFormat() and GetDateFormat() when displaying times/dates, and use the date/time picker common control when you need the user to enter a date/time.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
thanks for your help.
|
|
|
|
|
i use ms access 2000 to create my own address book which contain first name, last name and phone number. Very stupid address book
Now i want to try to use Visual C++ to map the correspond table field on the visual C++ form on each edit box to allow me to look through the record, add and delete record which i already done it using ODBC database method. It is very easy to follow the tutorial in the MSDN in Student Registration tutorial.
Next, i wish to synchronize the address book by pressing a button on the form. I have one address book in school and one address book at home. I wish to synchronize them. Of course, not through the network. Anyone have any idea?
|
|
|
|
|
Here is some pseudo timer code which calls ProcessData() twice per minute.
MyClass::OnTimer(UINT TimerID)
{
if(TimerID == MyTimer) {
KillTimer(MyTimer);
if (new_data) {
ProcessData();
} } }
If ProcessData() is written as follows then after approximately three hours
it will no longer be able to Open() the database.
MyClass::ProcessData()
{
CDatabase myDB;
if (myDB.Open()) {
do something
}
myDB.Close();
}
If it is written this way it appears to work fine.
MyClass::ProcessData()
{
CDatabase *myDB = new CDatabase;
if (myDB->Open()) {
do something
}
myDB->Close();
delete myDB;
}
The CDatabase class I am using is the CADODatabase class from a database article here on CodeProject. The class destructor appears to be correctly written. Also, a colleague of mine wrote his own database class a few years ago and it exhibited the same problem.
Could running it in debug mode be part of the problem?
Any thoughts as to what is happening here would be appreciated...
>>>-----> MikeO
|
|
|
|
|
A possibility is that the do something part is corrupting the stack (maybe going out of bounds on a built-in array?) so that the myDB memory space results affected.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|