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);
}
}
inbugable at 2007-11-9 13:31:34 >
# 2 Re: WriteFile issue
Sorry George, I just had to do that
inbugable at 2007-11-9 13:32:33 >
# 3 Re: WriteFile issue
You have to note that Named pipe write operations across a network are limited to 65,535 bytes .
sunny_sz at 2007-11-9 13:33:31 >
# 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
George2 at 2007-11-9 13:34:36 >
# 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
George2 at 2007-11-9 13:35:35 >
# 6 Re: WriteFile issue
You can always use sizeof(TCHAR)*(1+_tcslen( str )). 1 added for null-terminator.
S_M_A at 2007-11-9 13:36:33 >
# 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
George2 at 2007-11-9 13:37:37 >
# 8 Re: WriteFile issue
Yes but only if your code is built for either one based on project settings. If you build for multibyte but have an explicit unicode string you have to use sizeof(wchar_t)*(1+wcslen(str))
S_M_A at 2007-11-9 13:38:40 >
# 9 Re: WriteFile issue
Thanks S_M_A,

Yes but only if your code is built for either one based on project settings. If you build for multibyte but have an explicit unicode string you have to use sizeof(wchar_t)*(1+wcslen(str))

Your answer is clear.

regards,
George
George2 at 2007-11-9 13:39:37 >