|
|
|
I don't really know what I expected to see there...
|
|
|
|
|
|
I'm working on a bit of code that manages files and directories with operations such as copy, delete, archive to removable media, etc. If the program encounters an error while performing one of these operations, I want to be able to give the user some information as to the nature of the error, such as file not found, directory not found, access failure, invalid path, etc.
However, many of the functions I'm using, such as SHFileOperation, return only "successful" or "unsuccessful", and I can't find a way to get any information on the nature of the error on an "unsuccessful" return. Any ideas?
|
|
|
|
|
|
Where is it documented that SHFileOperation() uses GetLastError() ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It isn't. I incorrectly assumed SHFileOperation() called SetLastError() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
SHFileOperation already informs the user of any error, unless you use the FOF_NOERRORUI flag in your request.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Is there any documentation on what error messages SHFileOperation uses? I've tested the function a few times without the FOF_NOERRORUI flag, and it can sometimes return unsuccessful without displaying any error message.
|
|
|
|
|
|
hi i am new to c++ and i would like to know how i can put date into a varieble called a
and time into a varieble called b like(DDMMYY) and (2400)
^^ me noob
|
|
|
|
|
Something like:
int a = 290605;
int b = 0929;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
i mean how to let the program automaticly store todays date and the current time into the varieble when the that line of code is being runed
|
|
|
|
|
See CTime() - specifically CTime::GetCurrentTime() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Check out the time() function.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
so do i put it this way?
#include <iostream>
using namespace std;
int time;
int main (void)
{
time = CTime();
return 0;
}
but i tryed tis and i dosnt work pls giv me an example pls
|
|
|
|
|
nneodeath wrote:
so do i put it this way?
What does the compiler say?
nneodeath wrote:
time = CTime();
CTime is an MFC class. To instantiate one, use:
CTime time; To construct one with the current date and time, use
CTime time = CTime::GetCurrentTime();
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
i tryed it but i doesnt really work could u please show me what i am doing wrong
#include <iostream>
using namespace std;
CTime time;
int main (void)
{
CTime time = CTime::GetCurrentTime();
cout << time << endl;
return 0;
}
this is my code pls help me correct it so that the date and time goes like this
time variebles
HHMM <==this order
date variebles
DDMMYY<==this order
|
|
|
|
|
nneodeath wrote:
cout << time << endl;
Use:
cout << time.Format("%x") << endl;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
#include<iostream>
using namespace std;
CTime time;
int main (void)
{
CTime time = CTime::GetCurrentTime();
//cout << time << endl;
cout << time.Format(time) << endl;
return 0;
}
the outcome:
--------------------Configuration: tiemsam - Win32 Debug--------------------
Compiling...
tiemsam.cpp
C:\Documents and Settings\nick\Desktop\currently doing cpp project\tiemsam.cpp(4) : error C2146: syntax error : missing ';' before identifier 'time'
C:\Documents and Settings\nick\Desktop\currently doing cpp project\tiemsam.cpp(4) : error C2501: 'CTime' : missing storage-class or type specifiers
C:\Documents and Settings\nick\Desktop\currently doing cpp project\tiemsam.cpp(4) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
tiemsam.exe - 3 error(s), 0 warning(s)
please help me see wats the problem
|
|
|
|
|
Why do you have two CTime variables?
nneodeath wrote:
cout << time.Format(time) << endl;
This is wrong. See my previous post.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
Flace wrote:
With _MBCS defined, size of TCHAR is 1 byte, so you cant even multiply _tcslen with this
I'm confused by this statement. But the number of occupied bytes in your string will be :
<br />
int nBytes = (_tcslen(pszString) * sizeof(TCHAR));<br />
The sizeof() will return the number of bytes occupied per character. This will obviously vary depending if you are working in single byte or double byte character mode.
I Dream of Absolute Zero
|
|
|
|
|
If you know you have a multibyte string, you can simply use strlen() to obtain the number of bytes.
void SomeFunction(LPSTR pString)
{
int nChars = _mbslen(pString);
int nBytes = strlen(pString);
[...]
}
If you are using the TCHAR macros you can do it like this:
void SomFunction(LPTSTR pString)
{
int nChars = _tcsclen(pString);
int nBytes = _tcslen(pString) * sizeof(TCHAR);
}
Note _tcslen is different than _tcsclen .
If _UNICODE is not defined, _tcslen resolves to strlen , and sizeof(TCHAR)==1 .
If _UNICODE is defined, _tcslen resolves to wcslen , and sizeof(TCHAR)==2 .
So, _tcslen(pString) * sizeof(TCHAR) will give you the number of bytes in any case.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|