|
|
Hi all,
I am getting an error C2022: '65279' : too big for character at the line in bold below, What should I change here? This code works if I use wsprintfW and wszBuffer is WCHAR however I need this for multibyte and must use "_T" not "L"
Any advise?
Thanks,
Jayjay
if( pRegInfo->uTaskRegID == 0 )
{
GUID AppGUID, TaskGUID;
::CoCreateGuid(&AppGUID);
::CoCreateGuid(&TaskGUID);
WCHAR wszGUID[50], wszTaskGUID[50];
::StringFromGUID2(AppGUID, wszGUID, 50);
::StringFromGUID2(TaskGUID, wszTaskGUID, 50);
TCHAR wszBuffer[1025] = { 0 };
::wsprintf(wszBuffer,
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
_T("<applications xmlns=\"http://schemas.microsoft.com/windows/cpltasks/v1\" xmlns:sh=\"http://schemas.microsoft.com/windows/tasks/v1\">")
_T("<application id=\"%s\">")
_T("<sh:task id=\"%s\" needsElevation=\"%s\">")
#ifdef _UNICODE
L"<sh:name>@%s,-%ld</sh:name>"
L"<sh:keywords>@%s,-%ld</sh:keywords>"
L"<sh:command>%%systemroot%%\\system32\\control.exe /name %s</sh:command>"
#else
_T("<sh:name>@%hs,-%ld</sh:name>")
_T("<sh:keywords>@%hs,-%ld</sh:keywords>")
_T("<sh:command>%%systemroot%%\\system32\\control.exe /name %hs</sh:command>")
#endif // _UNICODE
_T("</sh:task>")
_T("<category id=\"%ld\">")
_T("<sh:task idref=\"%s\"/>")
_T("</category>")
_T("</application>")
_T("</applications>"),
wszGUID,
wszTaskGUID,
pRegInfo->dwRunLevel == 0 ? _T("false") : _T("true"),
szDllName, Info.uTaskRes,
szDllName, Info.uKeywordsRes,
Info.pstrCanonicalName,
pRegInfo->dwCategory,
wszTaskGUID);
::wsprintf(szGUID, _T("%ws"), wszGUID);
::lstrcpy(szTaskFileUrl, szDllFile);
::wsprintf(_FindLastOf(szTaskFileUrl, '.'), _T("_cpl%d.xml"), pRegInfo->iIndex + 1);
if( bRegister ) {
HANDLE hFile = ::CreateFile(szTaskFileUrl, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if( hFile == INVALID_HANDLE_VALUE ) return HRESULT_FROM_WIN32(::GetLastError());
DWORD dwWritten = 0;
::WriteFile(hFile, wszBuffer, ::lstrlen(wszBuffer) * sizeof(WCHAR), &dwWritten, NULL);
::CloseHandle(hFile);
}
else {
::DeleteFile(szTaskFileUrl);
|
|
|
|
|
I don't see a bold line. Error C2022 in the documentation says, "The octal number following a backslash (\) in a character or string constant is too big to represent a character". So I am guess that you are trying to assign a number greater than 255 for a char variable.
-Saurabh
|
|
|
|
|
Hi Saurabh,
It is this line
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
Thanks,
Jayjay
|
|
|
|
|
The first character is \xfeff which is 65279. This value cannot be stored in a char variable. I think you can split it into two characters for ANSI chars (\xfe\xff) and single char for wide-chars.
-Saurabh
|
|
|
|
|
Saurabh.Garg wrote: The first character is \xfeff which is 65279. This value cannot be stored in a char variable. I think you can split it into two characters for ANSI chars (\xfe\xff) and single char for wide-chars.
But:
Keep in mind how values are stored.On an Intel Machine: \xfeff should be reversed when broken up as: \xff\xfe.
Bram van Kampen
|
|
|
|
|
Hello
I have a strange behavior with a program I've made
I've first made a dialog box with an OpenGL display
Everything was working ok
Then I added a button in my dialog box then transfer my OpenGL calls in it (subclass from CButton)
The OpenGL drawing work ok on the button, but the timer on my calling dialog box freeze when I'm using the OpenGL functions
The timer resume normally when I close the dialog box
- The OpenGL call is the same as it was when it was directly on the dialog box
- When I deactivate the OpenGL calls, my timer work ok
Do anyone have an idea off what is happening?
Thank you
|
|
|
|
|
Hi everybody! I am developing an application in visual c++ (windows form application), and i want to set some of the parameters of my wireless card thru ndis (for instance the infrastuture mode). Can I do that ? how? any idea?
thaks!!!
Gloria.
|
|
|
|
|
how to write a code in VC++ for acquiring an image from the camera through activedcam card
|
|
|
|
|
jjvr wrote: how to write a code in VC++
What's going on? Did someone just outsource this project to you? What are the requirements?
led mike
|
|
|
|
|
!
Bram van Kampen
|
|
|
|
|
Hello again!
Using MFC, I am trying to implement an EDIT BOX and to print the content of it into a file.
I have associated a variable to the EDIT BOX, and that is CString varName.
When writing this variable into a log file, LOG.Write (varName, <not yet sure what length> ); , i get the result:
- for input: Shpid3r => S<square>h<square>p<square>i<square>d<square>3<square>r<square>.
I think that this is because using UNICODE character set, and every character in the CString is using 2 bytes, whilst using it into the Write() method, converts the string byte-by-byte.
Setting to use ANSI, creates an error (not finding a header file)... anyway my application should support unicode character set, even if logging will not meet unicode characters.
How should I do in order to get a proper logging?
Thank you!
|
|
|
|
|
You may:
- Convert your string to an ANSI one before writing it to the log (check out the T2A macro [^]).
or just use (a usually annoying feature of C++ )
- wofstream object to print the string (no need to convert it) to the log file.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
grid consists 10 rows. i want to sort only 5 rows based on the column selected. how to do that.
|
|
|
|
|
Member 4157987 wrote: grid...
Which one?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Member 4157987 wrote: i want to sort only 5 rows based on the column selected. how to do that.
Find out what colum is selected, and sort accordingly. Just ALWAYS make sure that you have more than one thing to sort!!
Bram van Kampen
|
|
|
|
|
I do'nt know what grid are you using : anyway I think in most cases you will
have some sort of callback of the type :
int onCompareTwoRows(int row1,int row2,int columnIndex){
}
where you define your comparision mechanism that would then be called by the sorting algo, in the grid implementation you are importing.
based on the column selected (columnIndex) you can just apply the comprarision on the 5 desired rows only :
int onCompareTwoRows(int row1,int row2,int columnIndex){
if(columnIndex==theColumnIwant){
if(row1 && row2 are in the 5 chosen rows set){
return -1,0 or 1 accrding to context..
}
}
else
return 0;
}
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|
I'm trying to override the global new operator:
void* __cdecl ::operator new(size_t nSize)
{
...
}
It is called for almost all cases. However in case of std::string allocation it does not work. The internal allocator of the std::string object still calls the default (CRT) global new allocator.
Any idea why?
Thanks,
Abyss
|
|
|
|
|
Maybe the STL authors want to control the allocation process just as you are trying to do.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Not sure, because for std::vector my new operator is called. And in some cases for the std::string too. In the particular case the given std::string calls my new operator, however my delete operator is not called. This of course is toxic, because the default CRT delete tries to release my pointer and the application crashes. My delete operator is defined as:
void __cdecl ::operator delete(void* ptr)
{
...
}
Not sure what is wrong here...
Thanks,
Abyss
|
|
|
|
|
You do know you have the ultimate documentation, don't you?
(That would be the source code)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Bram van Kampen
|
|
|
|
|
|
It means:
You designed the Software, and You wrote the Code, so You are the best person in the world to know what's it supposed to do or not do in the firstplace. None of us are in that priviledged position.
Bram van Kampen
|
|
|
|
|
Hello evryone.
How can I pass arguments call info + simple function address to a certain code that would
then be able to succefully call that function ???
For example I have a function like :
void sendHello(char* hello,int destID);
I want to pass to a certain code block A, the address of that function by mean of a void* variable, and
also pass someother "metadata" about arguments order and types, so that the code block A can
succeed to callback that function.
Is there sort of something that would like :
A::storeFunction( void*, metadata??)
such for example I can easily call :
A::storeFunction(sendHello,{{"byString","hello"},{"byInt","destID"}});
before the code block A can somehow, at a certain time needed succed to call the function he stored ??
??
Thank u in advance.
"The Awaited Saviour", Mohammed Baqir Al Sadr
|
|
|
|
|