Hi,
I want to concatenate a number to a PWCHAR string. Like Name1, Name2
etc.
The string available for me is an initialized PWCHAR. What is the
function in kernel, I can use to concatenate a number to this PWCHAR ?
If such a function is not available then, is there any way I can
implement this. I have to pass a PWCHAR to the function
InstallSubdevice() which has PWCHAR Name as one of the parameters.
Currently, I?m doing like :-
PWCHAR tecmpstr = L?Name1?;
InstallSubdevice(?.,?., tempstr,?.);
But the tempstr keeps changing depending on some index which should be
concatenated with the name. How do I achieve this ?
Regards
Esha
There are a lot of ways to achieve this. e.g.
WCHAR Result[???] = L"Name1";
WCHAR itoa_buffer[???];
UNICODE_STRING String1;
UNICODE_STRING String2;
String1.MaximumLength = sizeof(Result);
String1.Length = sizeof(L"Name1") - sizeof(WCHAR);
String1.Buffer = Result;
//Initialize String2 just like string1
String2.MaximumLength = sizeof(itoaBuffer);
String2.Length = 0;
String2.Buffer = itoaBuffer;
RtlIntegerToUnicodeString(Number, Base, &String2);
RtlAppendUnicodeStringToString(&String1, &String2);
InstallSubdevice( Result)
or you can simply use _snwprintf
You must carefully allocate the space for destination string, and then use
functions from NtStrSafe.h to fill it.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From: “Eshanye.K.P”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, April 21, 2004 10:30 AM
Subject: [ntdev] How to concatenate a number to PWCHAR string ?
> Hi,
>
> I want to concatenate a number to a PWCHAR string. Like Name1, Name2
> etc.
> The string available for me is an initialized PWCHAR. What is the
> function in kernel, I can use to concatenate a number to this PWCHAR ?
> If such a function is not available then, is there any way I can
> implement this. I have to pass a PWCHAR to the function
> InstallSubdevice() which has PWCHAR Name as one of the parameters.
> Currently, I’m doing like :-
>
> PWCHAR tecmpstr = L"Name1";
> InstallSubdevice(…,…, tempstr,…);
>
> But the tempstr keeps changing depending on some index which should be
> concatenated with the name. How do I achieve this ?
>
> Regards
> Esha
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>