"WIWA" <> wrote in message
news:41af8f5d$0$25072$...
> Hello,
>
> I have written a program that gets information from Active Directory. This
> is the function I'm using:
>
> void ADSysGetUserName(IADsADSystemInfo * pSys, char * data) {
> HRESULT hr;
> BSTR bstr;
> hr = pSys->get_UserName(&bstr);
> if (SUCCEEDED(hr)) {
> sprintf((char*)data, "%S", bstr);
> }
> SysFreeString(bstr);
> }
>
> I call it using:
>
> char temp[500];
> ADSysGetComputerName(pSys, temp);
>
> The problem I'm getting is that when a user's name contains special
> characters (such as ihv| ...) and I'm getting it, it modifies those
> characters. In the table below, you can see that D|vogrih (just a test
> name) is returned as D3vo~r\^. The values in the left column are the
> correct ASCII values.
>
>
> 68 D D
> 252 3 |
> 118 v v
> 111 o o
> 231 ~ g
> 114 r r
> 233 Z i
> 232 ^ h
>
>
> I was always under the impression that a char could also handle these
> special characters. Does anyone know what is wrong here? Should I use
> another type. Could anyone provide me with an example?
>
> Thanks in advance,
>
> WiWa
Are the values changing, or are they correct but your display of them as
text (using printf) is incorrect? Run it in a debugger and see whether you
get the correct values. Also,you'll probably want to use unsigned char for
whatever it is they get stored in, since you've got values that are greater
than 127. (And I have no idea what a BSTR is... nor any of that other
stuff. Looks like Microsoft-specific stuff. If you have problems specific
to Microsoft, you might want to ask in one of their newsgroups.)
-Howard
|