|
My brain is fried - is there an API I can call to do convert a digit CString to an int ? I suppose I could walk the CString and do a manual conversion, but I was looking for a Unicode analog of:
char szNumber [64];
strcpy (szNumber, "123");
long nValue = -1;
sccanf (szNumber, "%d", &nValue);
In other words:
CString strNumber = _T("123");
long nValue = -1;
xxx (strNumber, _T("%d"), &nValue);
Thanks,
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Dear All,
I am developing an application in MFC VC++ Version 6.0 for Windows 2000.
I am making an uninstallation program, in which i have to delete some files associated with my program and the application exe itself which is running.
ie. I am running EZ.exe, and at click of an event, I want it to be deleted itself after next restart.
Is there any way out?? I know that there are some pending rename operations like the one we use in MoveFileEx API, but how can we use it to delete the application .
Feel free to ask any further queries in this regards,
Thanks
Rohit Dhamija
|
|
|
|
|
From the MSDN documentation on MoveFileEx
If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
Magnus
|
|
|
|
|
You can also create a batch file which will start when windows starts and delete the files and the main exe with it...
Well... I am a beginner ...
|
|
|
|
|
Dear scolinks,
MoveFileEx worked exact. Thanks.
...
You can also create a batch file which will start when windows starts and delete the files and the main exe with it...
Answer) This is also a solution , but in this case who will clean (ie delete) the batch file ??? Again the problem remains there then !!
Rohit
|
|
|
|
|
uh... you can create a second batch for cleaning the first one!
Well... I am a beginner ...
|
|
|
|
|
MoveFileEx is the right way to do it.
But, a batfile can delete itself
This way you can call a batchfile from your program, make the batchfile loop while trying to delete your program, when your program exists the batchfile deletes it and can delete itself
- Anders
Money talks, but all mine ever says is "Goodbye!"
http://SourceLocker.net[^] SourceControl and DefectTracker Project.
nsms@spyf.dk <- Spam Collecting
|
|
|
|
|
Can anyone help me...
I have build a simple listening socket program using winsock2 in windows xp. when i start the listening socket it works fine.
i send 1000 concurent message in one time, the socket works fine. until i send 1000 message again, then the send application receive error message "address already in use" (WSAEADDRINUSE).
then i shutdown the listening application and start it up again, then i try to send a message again using the same port, i cannot connect to the listening port, it says the same error.
is there any way that i could done in order to get listening socket status if the send application receive that error. coz, once that error occure, i can't send any message to listening socket. i want to clean up the listening socket again so i can use it again.
thanks...
((
_; )
((
|
|
|
|
|
So you have 2 apps:
- a server
- a client
In the client you have the error WSAEADDRINUSE.
You probably try to recreate a socket with the same port in the client after you send the first 1000 messages. Are you sure that the first transfer completed succesfully? If not the port will be opened, hence your error.
If you shutdown the server while there are active connections to the socket, this will not close and the port will not be closed. Hence the error when you try to restart the server and it tries to bind on an already opened port.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Thanks for the reply,
yes i have 2 apps, n i think i have to explain how those two works.
server app works like any other server apps. it's listen to the port i have specify.
in the client, it works like this. if i want to send 10 message for example, for the first message i create socket then i send it to server, after i have send it, i close the socket right away. when i want to send another one, i use the same method again. the reason i do this, because i want to simulate my server as if it was hit by noumerous connection in one time.
the strange thing is, after the client receive that error, i shutdown the server, and i shut down the client. after that, when i try to connect to server without starting the server app, it retreive WSAEADDRINUSE rather than WSAECONNREFUSED error message.
i have to wait for sometimes, than after that i can receive WSAECONNREFUSED error in my client app, which specify that the current port is not in use.
during that time (when client app rec WSAEADDRINUSE with server app off), if i start my server app, it works just fine, there is no error message, as if it was in listen state normally. but when i try to send a message from the client app, i would receive WSAEADDRINUSE in my client app.
is there any explaination about this? n how i should deal woth this problem?
i was sure the transfer completed, coz i receive the message from the client n i close the client socket normaly too.
((
_; )
((
|
|
|
|
|
i want to convert the string "2003-8-27 20:30:26" to a CTime
object.how can i do?
thanks!
Habbit--Beginner In MFC
|
|
|
|
|
COleDateTime::ParseDateTime()
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I posted this in the FAQ section but didnt receive a reply, assuming that no one really visits that message board, I decided to post here, PLEASE feel free to delete that post, I am NOT cross-posting(at least I dont intend to anyways, )
I read FAQ 2.5[C++ Faqs] as well as the relevant topics on MSDN but didn't get this:
1) What is the difference between using *automatic pre compiled headers* and *creating/using pre compiled headers*[presumably only through using stdafx.h and stafx.cpp]
2) Which is better and why?
3) *When* is it advisable to use either and why.
Sorry I can't be more specific , but this is all I know at this time and am going crazy reading MSDN which offers little to me at this time.
Thanks in advance!
Any help will be appreciated.
|
|
|
|
|
My personal opinoin - I always use the "Automatic" option. It is nice because if a source file has the precompiled header (e.g., "stdafx.h") as its first include, it uses it. If not, it doesn't use precompiled headers for that file. You don't have to worry about any funky build steps to make the PCH either (I seem to recall running into situations where I have to build the PCH separately or specially if I use the "Use precompiled headers" option.
And for really small projects, with say one or two CPP files, I don't use precompiled headers at all.
I know that's not very comprehensive, but it's what works for me.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Thanks for the reply.
Please allow me to rephrase my question and ask a few more as well.
1) I do know *how* to use the stdafx.h/cpp files and hence the *Creating/using precompiled headers * options.
What I do now is that I include all Window and STL Headers that I need in the project in the stdafx.h file and then include this file as the firstinclude in every other file of the project and using the options, I select *Using precompiled headers * for all these files and *Create precompiled headers * for the stdafx.cpp.
So far so good.. or is it? Can someone please comment.
2) I include the statement
using namespace std;
within the stdafx.h file! Is that right?
3) When if at all would it be beneficial(implying reduced compile time and all the other benefits of using precompiled headers.....which are......? ) to use the *automatic precompiled header* option?
4) How does one use the automatic precompiled header option,
i)Select the option from the avialble compiler options
ii)Use the default or otherwise specify the name for the.pch file
iii)Use the
#pragma hdrstop
directive after including each and every header file that you need in eachand every file that needs to include them,
Can someone please confirm if this is right.
5) Is it better to have ONE header file [as I get currently] that has ALL the includes that might be needed by the entire project OR should one include each and eevry header file explicitly in the source files. Which in your opinion is a better option and why!
THANKS again.
|
|
|
|
|
1.
I use the "Automatic" becuase every now and then a file I need won't have "#inclue stdafx.h" in it. "Automatic" simply means, if a CPP File has, say "#inclue stdafx.h" then it assumes it is using a precompiled header. If not, go on and compile the file 'normally'. This also means you never have to go file by file and set up precompiled header info - you just have one setting for the whole project. The way you're doing it will work though, I just have my own preference.
2.
I probably wouldn't put "using std;" in there simply because that defeats the whole purpose of having "std" in a namespace. Although I suppose it is a convenience issue, really, it won't hurt anything if you konw you will never have name clashes with any of the std stuff.
3. See the answer to 1.
4. As far as "pragma hdrstop", I've never seen that in VC code, I do remember using it in Borland C++ (ah, remember those days ). The only stuff that gets precompiled is what's in "stdafx.h" (AFAIK.)
5. Here's the kind of stuff I put in my stdafx.h (or equivilant):
MFC and STL headers
My own headers for stable classes that rarely change but are included a lot
Any funky defines and such that should apply to every file in the project
It's a bad idea to have every header in your project in there, or to have one big header that includes everything. Two reasons:
It makes it very difficult to sort out components that you may someday move to another project or a common area.
If *any* include changes, you'll have to rebuild your WHOLE project.
I usually have one class per CPP/H pair. And just include whatever stuff is necessary when it is necessary. stdafx.h gets stuff that truly is common across all (or at least many) modules.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Other opinions vary;
1. Yes, that's fine.
2. I wouldn't necessarily have the 'using namespace', but I might put it in the top of selected sources that use 'std' stuff. I almost never have a 'using namespace' in a header.
3. No difference in terms of compile time etc between automatic and using/create.
4. I don't. Occasionally to include a C/C++ file from some legacy code this means having to turn off 'use precompiled headers' for the odd file, but hey, that's what the project settings are for.
5. Depends. I tend to have Win32, standard, STL, ATL and WTL headers only in stdafx, as they aren't going to change. Individual modules (CPP files) then have only the extra '#include's that they need. That way, altering a project specific header doesn't recompile the whole project.
Unrelated to the question but relevant, unless you're happy to waste hours -- use a source code management system.
Steve S
|
|
|
|
|
Guys, Anyone knows where I can download the Microsoft 'C' Compiler 6.00?
I need to make some changes to an old project built using this compiler and I need to recompile the project using the MS C 6.0 compiler.
I know that with some changes I could compile with MS VC++ or even Turbo C++, but my client _requires_ me to use MS C 6.0 compiler because of (reasons)...
modified 25-May-20 21:47pm.
|
|
|
|
|
Legally, you can't. It isn't part of MSDN (they only go back to VC++ 1.52c which is v7 or v8. I faced a similar problem here with a client who had source/executables but no compiler and they needed some changes, but fortunately, I've been using MS C since 5.00, and every time I upgraded, I kept the old disks. As time has gone by, I've had to copy them all to CD so that my newer machines can still access them, since 5 1/4" floppies aren't too common these days.
You *should* be able to use VC1.5 to do the work, then a final build with C6 if someone near you has a copy. I certainly ported a lot of stuff from 6 to VC++ 1.5 with very little work. Hardest was figuring out the right project settings.
I can understand why they want you to use C6. They probably feel it's safer, since that was the original tool, and unless you use C6, C7 (aka VC++1.0) or 1.5, you can't produce a DOS application.
Steve S
|
|
|
|
|
Hi Steve, thank you for getting back to me.
The changes to the project are already being done, I'll just need the compiler
Is there anyway I can buy it from Microsoft? I've searched MS site, but can't find anything.
modified 25-May-20 21:46pm.
|
|
|
|
|
We need to pass a struct from CMyapp to CMyDoc. Is it possible to do
this, and how painfull will it be.
Thanks in advance
-Fred
|
|
|
|
|
The app could (selectively) allow the doc could access it by exposing a getAtComplexData() API. Your doc would do:
CMyApp* pMyApp = (CMyApp *) AfxGetApp();
ASSERT (pMyApp != NULL);
ComplexData* pComplexData = pMyApp->getAtComplexData (this);
if (pComplexData != NULL) {
...
}
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
You have a few options available.
As the structure exists in the application class (CMyApp), you can create a member function that returns the address of this structure.
Now, if this method is called from inside CMyDoc, the document has the address of the structure, and can operate on it freely, providing that both objects reside on the same thread. If they do not, things get more complicated.
Alternatively, taking an advanced step from the section above, you can create a structure into CMyDoc as well, then get a pointer from CMyApp and use memcpy to copy the structure data from CMyApp to CMyDoc. Now, CMyDoc contains a copy of the structure.
The previous posted created an example piece to show you how to access the application object at run-time. Use this method to call the function that returns the structure address.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi everyone I get an assertion error when I try to iniatialize the contents of the controls of CDialog derived class of Edit boxes and Combo boxes. I try to initialise them at the constructor. Of course I have attached member variables to each control.
The initialization code works well when for instance I trigger, execute it by a button click.
Can anyone help?
|
|
|
|
|