如何连接两个unicode字符串 [英] How to concatenate two unicode strings

查看:160
本文介绍了如何连接两个unicode字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我已经使用了以下代码:

Hi I've used the following code for this :

DbgPrint("\n File name volume is %wZ",&dosName);
    str.MaximumLength = (USHORT)dosName.Length;
    //status = RtlAppendUnicodeStringToString(&teststr, &Data->Iopb->TargetFileObject->FileName);
    status = RtlUnicodeStringToAnsiString(&str, &dosName, TRUE);
    DbgPrint("\n status is :  %s",status);
    DbgPrint("\n New  Data %Z", str);

    DbgPrint("\n Data %wZ", &Data->Iopb->TargetFileObject->FileName);





但是这个根本不工作且状态显示为null DebugView中的值



请建议我一些替代方案



but this one is not working at all and status is showing null value in DebugView

please suggest me some alternatives

推荐答案

<$ c $返回的状态值c> RtlUnicodeStringToAnsiString 不是字符串而是数值:请参阅 https:// msdn.microsoft.com/en-gb/library/cc704588.aspx [ ^ ]。
The status value returned by RtlUnicodeStringToAnsiString is not a string but a numeric value: see https://msdn.microsoft.com/en-gb/library/cc704588.aspx[^].


NameLength = (USHORT)dosName.MaximumLength + Data->Iopb->TargetFileObject->FileName.MaximumLength + 2;
    NameBuffer = ExAllocatePoolWithTag(PagedPool,NameLength,NC_MAPPING_TAG);
    NameString.Length = 0;
    NameString.MaximumLength = NameLength;
    NameString.Buffer = NameBuffer;
    RtlCopyUnicodeString(&NameString, &dosName);
    RtlAppendUnicodeStringToString(&NameString, &Data->Iopb->TargetFileObject->FileName);



这里我们需要为字符串分配池。但小心池分配可能导致BSOD。


Here we need to allocate pool for string. But Be careful pool allocation may lead to BSOD.


这篇关于如何连接两个unicode字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆