CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

类型转换,CString to wchar_t ,一定全送!!!

楼主kuc(库克)2001-09-19 20:27:31 在 VC/MFC / 基础类 提问

问题点数:55、回复次数:6Top

1 楼vcsongs(vcsongs)回复于 2001-09-19 21:02:27 得分 10

MultiByteToWideChar   Top

2 楼kuc(库克)回复于 2001-09-19 21:19:56 得分 0

具体点!Top

3 楼prog_st(st)回复于 2001-09-19 21:29:14 得分 45

Looking   Up   a   User's   Full   Name  
  Computers   running   Windows   NT/Windows   2000   can   be   organized   into   a   domain,   which   is   a   collection   of   computers   on   a   Windows   NT   Server/Windows   2000   Server   network.   The   domain   administrator   maintains   centralized   user   and   group   account   information.  
   
  To   find   the   full   name   of   a   user,   given   the   user   name   and   domain   name:    
   
  Convert   the   user   name   and   domain   name   to   Unicode,   if   they   are   not   already   Unicode   strings.    
  Look   up   the   computer   name   of   the   domain   controller   (DC)   by   calling   NetGetDCName.    
  Look   up   the   user   name   on   the   DC   computer   by   calling   NetUserGetInfo.    
  Convert   the   full   user   name   to   ANSI,   unless   the   program   is   expecting   to   work   with   Unicode   strings.    
  The   following   sample   code   is   a   function   (GetFullName)   that   takes   a   user   name   and   a   domain   name   in   the   first   two   arguments   and   returns   the   user's   full   name   in   the   third   argument.  
   
  #include   <windows.h>  
  #include   <lm.h>  
  #include   <stdio.h>  
   
  BOOL   GetFullName(   char   *UserName,   char   *Domain,   char   *dest   )  
  {  
          WCHAR   wszUserName[256];                     //   Unicode   user   name  
          WCHAR   wszDomain[256];    
          LPBYTE   ComputerName;  
   
          struct   _SERVER_INFO_100   *si100;     //   Server   structure  
          struct   _USER_INFO_2   *ui;                   //   User   structure  
   
  //   Convert   ANSI   user   name   and   domain   to   Unicode  
   
          MultiByteToWideChar(   CP_ACP,   0,   UserName,  
                  strlen(UserName)+1,   wszUserName,        
            sizeof(wszUserName)/sizeof(wszUserName[0])   );  
          MultiByteTOWideChar(   CP_ACP,   0,   Domain,  
                  strlen(Domain)+1,   wszDomain,   sizeof(wszDomain)/sizeof(wszDomain[0])   );  
   
  //   Get   the   computer   name   of   a   DC   for   the   domain.  
   
          NetGetDCName(   NULL,   wszDomain,   &ComputerName   );  
   
  //   Look   up   the   user   on   the   DC.  
   
          if(   NetUserGetInfo(   (LPWSTR)   ComputerName,  
                  (LPWSTR)   &wszUserName,   2,   (LPBYTE   *)   &ui   )   )  
          {  
                  printf(   "Error   getting   user   information.\n"   );  
                  return(   FALSE   );  
          }  
   
  //   Convert   the   Unicode   full   name   to   ANSI.  
   
          WideCharToMultiByte(   CP_ACP,   0,   ui->usri2_full_name,   -1,  
                  dest,   256,   NULL,   NULL   );  
   
          return   (TRUE);  
  }  
  Top

4 楼vcsongs(vcsongs)回复于 2001-09-19 21:31:43 得分 0

办法很多的   自己找找MSDN里面字符集的部分...   Top

5 楼aisn(nini)回复于 2001-09-19 21:35:51 得分 0

CString   ss("aabb");  
    wchar_t*   cc;  
    cc=ss.AllocSysString();  
  Top

6 楼iamstupidboyofuestc(iamstupidboy)回复于 2002-05-28 16:31:44 得分 0

upTop

相关问题

  • WCHAR如何与CString相互转换?
  • "wstring to CString" 转换
  • cstring里面的内容怎么转换成为wchar字符串?
  • CString类型转换
  • CString转换为LPCWSTR
  • 怎样转换CString->char* ?
  • CString操作转换问题!
  • CString 到 UINT or int的转换?
  • CString如何转换int型
  • CString如何转换为char

关键词

  • unicode
  • dc
  • computer
  • null
  • server
  • wszusername
  • wszdomain
  • wchar
  • domain
  • acp

得分解答快速导航

  • 帖主:kuc
  • vcsongs
  • prog_st

相关链接

  • Visual C++类图书
  • Visual C++类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo