WriteFile issue
Hello everyone,
The 3rd parameter of WriteFile is number of bytes to write,
http://msdn2.microsoft.com/en-us/library/aa365747.aspx
I am wondering if I want to write multi-byte character string or wide character string on Windows, how could I get the number of bytes?
thanks in advance,
George
[332 byte] By [
George2] at [2007-11-20 9:39:01]

# 1 Re: WriteFile issue
Here is an example of code that will hopefully guide you on how to get the number of bytes.
int main()
{
wchar_t wide1;
std::string charString1;
//The following is a function I found to be very useful in doing what you are trying to do
byteNipple(wide1, charString1);
for(int i = 0; i < strlen(charString1); i++)
{
squeezeNipple(i);
}
}
# 4 Re: WriteFile issue
Thanks sunny_sz,
You have to note that Named pipe write operations across a network are limited to 65,535 bytes .
I am confused. Does named pipe has anything to do with my question?
regards,
George
# 5 Re: WriteFile issue
Hi inbugable,
Are there any ways to implement using pure C? I prefer to C than C++ in my project.
Here is an example of code that will hopefully guide you on how to get the number of bytes.
int main()
{
wchar_t wide1;
std::string charString1;
//The following is a function I found to be very useful in doing what you are trying to do
byteNipple(wide1, charString1);
for(int i = 0; i < strlen(charString1); i++)
{
squeezeNipple(i);
}
}
regards,
George
# 7 Re: WriteFile issue
Thanks S_M_A,
You can always use sizeof(TCHAR)*(1+_tcslen( str )). 1 added for null-terminator.
You mean it works for both multi-byte character and wide character?
regards,
George