问题描述
我正在编写一些代码来读取可用磁盘空间,如下所示:
I am writing some code to read the free disk space as follows:
//declare the params to pass into the method to check disk usage
ULARGE_INTEGER uliFreeBytesAvailable;
ULARGE_INTEGER uliTotalNumberOfBytes;
ULARGE_INTEGER uliTotalNumberOfFreeBytes;
//init the params to pass into the method to check disk usage
uliFreeBytesAvailable.QuadPart = 0L;
uliTotalNumberOfBytes.QuadPart = 0L;
uliTotalNumberOfFreeBytes.QuadPart = 0L;
if(GetDiskFreeSpaceEx(lpDirectoryName,
&uliFreeBytesAvailable,
&uliTotalNumberOfBytes,
&uliTotalNumberOfFreeBytes))
然后,我得到uliTotalNumberOfFreeBytes.QuadPart,它是一个DWORD64,我需要使用socket :: send方法通过Windows套接字将其发送到另一个应用程序,要求将数据作为char *发送.请有人帮助我将DWORD64转换为char *,或告诉我是否有替代方法可以执行此操作.
我可以将DWORD64转换为双精度型,因此,如果有人可以告诉我如何将双精度型转换为char *,这也将非常有用:)
I then get the uliTotalNumberOfFreeBytes.QuadPart which is a DWORD64 and I need to send it to another application via a windows socket using the socket::send method requires the data to be sent as a char*. Please could somebody help me to convert the DWORD64 to a char*, or tell me if there is an alternative option for doing this.
I can conver the DWORD64 to a double so if someone could tell me how to convert a double to a char* that would be very helpful too :)
推荐答案
ULARGE_INTEGER val = 123;;
send(s, (char *)&val, sizeof(ULARGE_INTEGER), 0);
这篇关于无法将DWORD64或double转换为char *以通过套接字发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!