|
Hi I am using the function WideCharToMultiByte and it is giving the following error.
error C2664: 'WideCharToMultiByte' : cannot convert parameter 3 from 'class CString' to 'const unsigned short *'
Dhiraj Kumar Saini.
|
|
|
|
|
Dhiraj kumar Saini wrote: cannot convert parameter 3 from 'class CString' to 'const unsigned short *'
show how you're using it please...
|
|
|
|
|
hi,
I am using it as
int lenA = ::WideCharToMultiByte(CP_ACP, 0, word, lenW, 0, 0, NULL, NULL);
where word is declared as CString
Thanx.
Dhiraj Kumar Saini
|
|
|
|
|
just a guess, what are you trying to do here ?
converting your CString object into a MultiBytes String ?
if so, why don't you just use CT2A() and such functions ?
|
|
|
|
|
I guess you don't need such call. See [^].
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]
|
|
|
|
|
In general, if you need to convert from wide char to multi byte strings (or the opposite) means that you have a design issues. You should stick to TCHAR routines so that your code can be compiled with or without UNICODE. I suggest you read this excellent article[^], you'll learn a lot of very usefull stuff, and it is certainly not a waste of time.
|
|
|
|
|
Cedric Moonen wrote: In general, if you need to convert from wide char to multi byte strings (or the opposite) means that you have a design issues.
I don't agree. There are many programs that need to deal with input in different encodings and it makes a perfect sense to convert all this text to Unicode before processing it.
|
|
|
|
|
Yes, I fully agree with you. But if you look closely at his question (and some others), and moreover the post from CPallini, then you can see that there is something wrong with his design. When you have a quite 'basic' application (MFC in this case) and only interact with the user through the UI, then in general (but again, there might be exceptions) you don't have to use a lot of string conversions. That's what I wanted to say (well, I agree, it was not very clear ). Anyway, reading the link I provided to him is always usefull.
|
|
|
|
|
Since the parameter 3 of the WideCharToMultiByte must be a wide char string and your CString object doesn't provide a suitable cast operator, I guess your CString instance is already ANSI (i.e. you're not doing a UNICODE build) and doesn't need to be converted.
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]
|
|
|
|
|
For unicode to ansi conversion and vice verse, better use macros such as A2W and W2A . They are more easier to use. Check here[^] for code snippet.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
The macros are outdated. There are now templates in the ATL (String constrcutors) to deal with that tasks.
Greetings from Germany
|
|
|
|
|
They are outdated? Well, Thanks for the info.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Since you do not have Unicode defined, word is not going to be a wide, thus no conversion is required.
"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
|
|
|
|
|
Hello evrybody.
I would like to know how can I retriev the program path once it is installed.
When my executable is launched I would like to acces program ressources like images, xml files.
These are all situatted in relative paths : ie in directories insidethe same dir as the executable it self.
The problem is that many utility functions that loads the ressources only accepts full paths, ie they would not accept something like the following :
./BMPs/tunisia_flag.bmp
So How can I translate that dot (.) to them, how to retrieve the application path ?
Is it possible at least to store the user chosen installation path of the application into registry at installation time, using the SetupProject type so to be retrieved by the application at run time ?
Thank you in advance.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
|
You can use GetCurrentDirectory [^] function to retrieve the directory when the application is launched and store it for later use.
Regards,
Sandip.
|
|
|
|
|
That won't work if the program is launched with a non-default (i.e. different from EXE's directory) working directory.
Judy
|
|
|
|
|
Hi All
I want to show all file folder which is present in USB Device.At this time i am geting only file name.And main problem is that when device is blanck then it is showing some Dummy line. Show how can i remove that problem..
Code is here
DWORD dwDrives=GetLogicalDrives();
if(0==dwDrives)
{
return FALSE;
}
DWORD dwCount=0;
char chDriveLabel='A';
char szRootpath[5]={0,0,0,0,0};
while(dwDrives !=0)
{
if ((dwDrives & 1) != 0)
{
sprintf(szRootpath,"%c:\\",chDriveLabel);
//removable drive
if(DRIVE_REMOVABLE==GetDriveType(szRootpath))
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
//Removable dirve lable
// std::cout <<"Files in " << szRootpath << std::endl;
m_ListCountries.AddString(szRootpath);
//* represent search all files and directories
szRootpath[3]='*';
hFind=FindFirstFile(szRootpath,&FindFileData);
if (INVALID_HANDLE_VALUE == hFind)
{
// return FALSE;
}
// List all the files in the directory .
do
{
//ignore the sub directories
if (!(FindFileData.dwFileAttributes &
FILE_ATTRIBUTE_DIRECTORY))
{
m_ListCountries.AddString(FindFileData.cFileName);
}
}while (FindNextFile(hFind, &FindFileData) != 0);
FindClose(hFind);
}
}
dwDrives = dwDrives >> 1;//next drive
chDriveLabel++;
}
return true;
Plz help me
modified on Wednesday, August 20, 2008 5:45 AM
|
|
|
|
|
Sir,
since yesterday, don't you see that your [code][/code] tag does work ?
use HTML (through the buttons below the typing area)...
|
|
|
|
|
|
but you still can edit and modify your message
|
|
|
|
|
now i do it but what about my main problem..
|
|
|
|
|
NewVC++ wrote: if (INVALID_HANDLE_VALUE == hFind)
{
// return FALSE;
}
Why don't you handle the FindFirstFile failure?
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]
|
|
|
|
|
NewVC++ wrote: At this time i am geting only file name.
Which is all you should be getting by using the cFileName member. The WIN32_FIND_DATA structure contains no path information as you already have access to that.
NewVC++ wrote: Plz help me
When you used the debugger to step through your code (which I'm sure you did ), what did you find?
"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
|
|
|
|
|
Hi,
I am using CRegKey class in my project and working on visual studio butu it is giving the following error.
error C2039: 'QueryStringValue' : is not a member of 'CRegKey'
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE\atlbase.h(4714) : see declaration of 'CRegKey'
Please any one tell me whats the porblem.
Dhiraj Kumar Saini
|
|
|
|