|
Instead of
ShellExecute(NULL,_T("open"),_T("cmd.exe"),_T("/C Test.bat"),0,SW_SHOW);
use either this:
ShellExecute(NULL, _T("open"), _T("cmd.exe"), _T("/C C:\\Test.bat"), NULL, SW_SHOW);
or this:
ShellExecute(NULL, _T("open"), _T("cmd.exe"), _T("/C Test.bat"), _T("C:\\"), SW_SHOW);
Note that the two solutions are not equivalent. In the second solution the current directory of your batch file will be C:\ while in the first case cmd.exe will inherit the current directory of the program from which you call ShellExecute() .
|
|
|
|
|
Hi all,
I am trying to write one string to a file.But i am getting only one character
saved in my Text.txt file.Output text file contains only "a" in it.
How can i get whole string saved in my text file.
Here is the code i am trying:
FILE *fptr;
CString Text;
Text = "asdasdasdasd";
fptr = fopen("D:\\Test.txt","w+");
if(fptr== NULL)
exit(1);
fprintf(fptr ,"%s",Text);
fclose(fptr);
If i write it as ""asdasdasdasd"" instead of passing the CString,it writes in the text file
fprintf(fptr ,"%s",""asdasdasdasd"");
Can anyone help me,where i am going wrong.
Thanks
Manju
|
|
|
|
|
I suspect your CString may be defaulting to Unicode (check your project settings), so it appears as though you have only written a single character. Try using CStringA and see what happens.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I suspect you are right.
Veni, vidi, vici.
|
|
|
|
|
No, I think pasztorpisti is right, the string needs to be cast to LPCTSTR to get the content.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Now I'm quite confident you are right.
Veni, vidi, vici.
|
|
|
|
|
I hope your confidence is not misplaced.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
The Text parameter you pass to fprintf() is a CString object, and and the %s format specifier expects a (const char*) or (char*) there. Instead of this you are pushing the whole CString object to the stack and the first 4 bytes of that CString instance are used as a (const char*). You have to convert the CString to either (const char*) or (char*) before using it with fprintf() . A more strict compiler like g++ would warn you about passing a non-pod object to a vararg function.
|
|
|
|
|
Are you building your project with "Use Unicode Character Set" or "Use Multi-Byte Character Set" character set. Change it to "Not Set"
Other alternative would be to use string instead of CString.
or like this with the above options set:
FILE *fptr;
CString Text;
Text = "asdasdasdasd";
fptr = _wfopen (_T("D:\\Test.txt"),_T("w+"));
if(fptr== NULL)
exit(1);
fwprintf(fptr,_T("%s"),Text);
fclose(fptr);
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
|
I'm experimenting with creating my first COM class. I named the class ComClass when I used the wizard to add a simple ATL object to my MFC DLL that has ATL support.
The problem is that the generated header file for my class has this line in it:
#include "ComClass_i.h"
The named file does not exist in my project directory. I assume it was supposed to be generated when I created the class.
What did I do wrong?
SOLUTION:
It turns out that the missing file gets automatically generated when you build the project! So all I had to do was build it, and the file was created.
The difficult we do right away...
...the impossible takes slightly longer.
modified 23-Aug-12 14:07pm.
|
|
|
|
|
Hi,
I just got an error converting a VS 2008 project to 2010
"Can not view XML input using XSL style sheet Please correct the error and click the
refresh button or try again Later
Can anyone help
Thanks
|
|
|
|
|
And how is this a C++ question? Please make an effort to use the correct forum for your questions.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I looked around and couldn't find an appropriate forum
|
|
|
|
|
You couldn't find this one[^]?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Sorry u right I was looking in the wrong place
Thanks
|
|
|
|
|
Why are all posts expanded now by default?
It is so ugly and I can see nothing except “HOW TO ANSWER A QUESTION”.
Could you change it to previous style? Or I have to leave.
.
|
|
|
|
|
The forum is the same as it's always been. Did you try clearing your cache?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Kidding!
Veni, vidi, vici.
|
|
|
|
|
Check the "Layout" drop down above the messages.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
HI,
I have a application similar to auto cad, in which we can draw line, circle, etc in client area using mouse or command.
Now i need to add a feature, so that the users of this application should be able to pan their drawings in client area using mouse left button. (like one in auto cad or pdf reader). I can use win32 API or MFC to achieve this.
It well be great of some one can help me in this regard, with some sample code.
Thanks in Advance
|
|
|
|
|
You just need to add code to your mouse handler to capture the amount of movement and use that information to adjust a variable which tells your program how far to the left or right the window should be moved. Then call InvalidateRect() [^] to tell the system that your window needs repainting. In your OnPaint() handler you use the stored variable to repaint that part of your data that falls within the physical window.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
ok, after getting x and y coordinates which API should I use to reset the x and y coordinates?
Thank you.
|
|
|
|
|
Member 9353776 wrote: after getting x and y coordinates which API should I use to reset the x and y coordinates? What do you mean by this? As I said in my reply, your program needs to capture the mouse movement and adjust the x and y values by the number of pixels moved. In your OnPaint() function you will be copying some part of your image onto the application's window. I assume the image (drawing) is larger than the window on which it is being drawn, so you just select the top left point from which to start based on the x and y values previously captured.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
You may also like to read this section of the GDI reference[^], which helps to visualise how this sort of problem can be addressed.
One of these days I'm going to think of a really clever signature.
|
|
|
|