我想在通过流发送之前将wchar_t
变量转换为 a 。BYTE *
我有
wchar_t val[] = L"abc";
我尝试使用:
BYTE * bytes = (BYTE *)val;
读取字节时,我没有所有字符;我只有第一个字符-"a"
我想,我转换得不好wchar_t
。
我究竟做错了什么?
编辑 :
static void DASH_process_receive(rdpSvcPlugin* plugin, wStream* data_in)
int bytes;
wStream* data_out;
DASHPlugin* DASH = (DASHPlugin*) plugin;
fprintf(stderr, "DASH_process_receive:\n");
if (!DASH)
{
fprintf(stderr, "DASH_process_receive: DASH is nil\n");
return;
}
/* process data in (from server) here */
/* here we just send the same data back */
bytes = Stream_Capacity(data_in);
fprintf(stderr, "DASH_process_receive: got bytes %d\n", bytes);
wchar_t val[] = L"abc";
bytes = Stream_Capacity(data_in);
if (bytes > 0)
{
fprintf(stderr, "size wcslen val %zd\n", wcslen(val));
fprintf(stderr, "size of val %zd\n", sizeof(val)); //I Have 16
data_out = Stream_New((BYTE*)val, sizeof(val));
Stream_Copy(data_out, data_out,sizeof(val));
/* svc_plugin_send takes ownership of data_out, that is why
we do not free it */
bytes = Stream_GetPosition(data_out);
fprintf(stderr, "DASH_process_receive: sending bytes %d\n", bytes);
svc_plugin_send(plugin, data_out);
}
Stream_Free(data_in, TRUE);
}
编辑:读取数据
WTSVirtualChannelRead(VirtChannelParamsStart, 20000, (PCHAR)Message, sizeof(Message), &ulBytesRead))
unsigned short Message[1024];
CString paramsPourStarter;
paramsPourStarter = Message;
SetDlgItemText(IDC_ED_DASH_RESU,paramsPourStarter);