|
Unless you have a good reason to don't use any of the old CRT string functions. Instead use a string class such as MFC's CString or STL's std::string .
Steve
|
|
|
|
|
The buff is char *.
Could tell how to do this strcpy(buff, "#...") with simpliest method?
Please help!
|
|
|
|
|
Don't use char* at all (unless you have a compelling reason). If you're using MFC try using CString instead. e.g.
CString MyString1 = "Hello";
CString MyString2 = "world";
CString MyString3 = MyString1 + " " + MyString2 + ".";
CString MyString4 = MyString3;
AfxMessageBox(MyString4);
No explict buffers, no memory allocation, no buffer overruns and no worries.
Steve
|
|
|
|
|
Thank you very much!
It's alright now!
|
|
|
|
|
In direct answer to your question, to disable the warning and (automatically) to use another function, then include this line in your code:
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
This will automatically substitute secure versions of CRT functions, e.g., it will substitute the secure version strcpy_s for its unsecure counterpart strcpy. The benefit is that you do not need to make any changes to your existing code.
See "Secure Template Overloads" at http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx[^].
To read more about secure vs. non-secure CRT functions, see "Security Enhancements in the CRT" at http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx[^].
Mike
|
|
|
|
|
|
If you want to go with CRT functions, you can go its secure version strcpy_s .
Refer this[^] for more information.
[Edit] This link is already provided in Mike's reply [Edit]
|
|
|
|
|
|
Hi,
I use WinHttp to download files/pages from http or https sites. I need an progress bar but I can't find out how to get size of file which will be downloaded. Any idea ?
-----------
Mila
|
|
|
|
|
Did you try the 'IBindStatusCallback' interface? (I am not sure if it will work with HTTPS)
|
|
|
|
|
I believe everyone has seen the “favorites” or bookmarks menu in IE, it has
the amazing ability to allow the user to drag object from outside the
application (the desktop, exporer you choose), the user can also accommodate
the menu items inside the menu by dragging them around.
I know I’ve to set MNS_DRAGDROP dwStyle for the menu by using
SetMenuInfo.
I’m able to catch WM_MENUDRAG messages when I start dragging menuItems but i
dont know how to continue processing this event, i know i've to return either
MND_ENDMENU or MND_CONTINUE.
Im barley at the beginning and I was looking for tome tips and notes about
this issue, maybe someone has already done something similar before.
Thanks.
|
|
|
|
|
benjamin23 wrote: but i
dont know how to continue processing this event
You call DoDragDrop[^]
led mike
|
|
|
|
|
Well, i´ve done that, i can drag things arround in a verry wird way, only works for items inside the menu, drop doesnt work it will refuse to, items dont change, im starting to think that this will be a little more difficult than i think.
1 Lots of OLE sh*t involved, implement DragDropHelper, IDropTargetHelper and maybe IDragSourceHelper ?
2 What about dynamic menus & ownerdraw ?
3 No code examples not even at msdn, and i mean no where, im starting to browse chinese web pages.
|
|
|
|
|
I have to use a DOS Window in background and have to use DOS commands to run some actions.
Can VC++ 6.0 launches DOS Window (& Minimize it) then issues some standard commands?
Thanks for any help
-- modified at 16:50 Tuesday 12th December, 2006
|
|
|
|
|
Are you sure that you must use DOS? Non-programmers often call console programs DOS programs (they are not) and they call command-prompt windows DOS boxes. Command-prompt windows can execute a variety of application types, not just DOS applications.
There are articles about redirecting standard input and standard output. I am not sure that that works for true DOS windows but it is the most likely solution.
Depending on the program, it might be difficult to do what you need to do. It might seem that all "DOS" programs are created equal, but they are not. It depends on the program whether or not you can control it from another program.
|
|
|
|
|
Yes, I do. However, Steve has just shown me how to do it.
Thanks for the advices and I will keep it in mind!
|
|
|
|
|
The samples that Stephen provided are not DOS commands or programs.
The System function is very simple. It is likely you will need to do something more than what it can do. If so, then it is likely easier to use equivalent functions that don't need a separate process.
Also, the System function executes the command shell, which you might not need.
|
|
|
|
|
#include "StdAfx.h"
#include <process.h>
int main()
{
system("echo Hello world!");
system("dir");
system("tree");
return 0;
}
Steve
|
|
|
|
|
Wow, you make it so easy. It is exact what I need ... I thought it must be hard to do it!
By the way, is there any method to make the MS DOS stay (not disappear) but in MINIMIZE mode (stay in the task bar)?
Many thanks Steve, I am really appreciate it! :->
|
|
|
|
|
The easiest was would be to lanuch your application via a shortcut and set the details on the shortcut.
Steve
|
|
|
|
|
The application is minimized as you suggested, but the MS DOS Window disappears after 0.5 second following each command system("...");
- Is it very difficulty to have MS DOS Window stay? Because I need to verify what it shows after a command excecuting!
|
|
|
|
|
You could try something like this:
#include "StdAfx.h"
#include <process.h>
#include <conio.h>
int main()
{
system("echo Hello world!");
system("dir");
system("tree");
system("echo Press any key...");
getch();
return 0;
}
Steve
|
|
|
|
|
It is the same, I did try system("pause"); It is pause but the previous MS DOS Window still disappear! So it shows an empty MS DOS Window ... but it stay there until I press a key!
|
|
|
|
|
Can you describe your application a little. For example, is it a console application or a Win32 application?
Steve
|
|
|
|
|
It is a WIN32 MFC application
|
|
|
|