CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VC/MFC >  基础类

VC++中的数据类型

楼主sunjet2000(小菜)2003-12-02 08:09:48 在 VC/MFC / 基础类 提问

我在一些程序中看到把内存偏移量用DWORD来表示,用int不行吗?我觉得DWORD总是怪怪的不是很熟悉。用他有什么好处吗?还有在图形的坐标了,图形的范围了。我看到有的程序用double,有的用float类型,我应该用什么类型比较好呢?如果我在一个程序里都用了这两个类型,在类型转换的过程中应该注意什么呢?会不会是数据丢失呢?还有呀,别闲我烦哦。。。还有您看有好多程序里都用了LPVOID、LPCTSTR   这些个指针,您说这些指针比平常的指针有什么好处吗?大家踊跃发言呀!为了中国的崛起而回帖!!! 问题点数:100、回复次数:13Top

1 楼wyz_csdn(网语者)回复于 2003-12-02 08:33:15 得分 0

这些都是VC里定义的宏。看MSDN帮助就行了Top

2 楼mfc168(子非鱼)回复于 2003-12-02 08:41:08 得分 0

DWORD是无符号的32位的整型,int为16位  
   
  float为   4字节,表示范围   3.4E   +/-   38   (7   digits)    
  double   为8字节   表示范围   1.7E   +/-   308   (15   digits)    
  最好用double,转换过程中,在从double转为float的时候会出现数据丢失,反之不会  
   
  LPVOID、LPCTSTR   都是长指针,为32位Top

3 楼nkwesley(江南丝竹)回复于 2003-12-02 08:41:09 得分 0

对,多研究MSDN好处多多啊  
  Top

4 楼sxslyy(孤松傲雪)回复于 2003-12-02 08:57:35 得分 0

markTop

5 楼sxslyy(孤松傲雪)回复于 2003-12-02 09:01:50 得分 0

mfc168(闶阆——项目开发中)   (   )   :  
  我认为VC中int是有符号32位(4字节)  
  没有什么长指针,指针都是4个字节32位长.  
  可以用sizeof(int),sizeof(LPSTR)看看  
  你记错了吧!Top

6 楼sunjet2000(小菜)回复于 2003-12-02 09:08:12 得分 0

mfc168(闶阆——项目开发中)   您给我这些变量的单位我也知道呀。但是这些变量的单位和选择这个变量有什么关系呢?还有您说:LPVOID、LPCTSTR   都是长指针,为32位。这我也知道,但是为什么不用短指针而用长指针呢?我是问为什么用他。  
  Top

7 楼greensofter(MC.CN)回复于 2003-12-02 09:33:51 得分 0

int是有符号32位(在32位系统中),DWORD是无符号32位。用32位的指针寻址范围更大。Top

8 楼iicup(双杯献酒)回复于 2003-12-02 09:34:24 得分 60

DWORD   永远是32位  
  int   可能是32位,也可能是16位,  
    视机器编译器和编译选项而定。  
    将来是64位也有可能。  
  Top

9 楼derryzhang(雨田)回复于 2003-12-02 10:35:54 得分 0

Right!~~Top

10 楼xiaodongliu(阿东)回复于 2003-12-02 10:36:27 得分 0

msdn或者多看看vc++技术内幕Top

11 楼farfh(阿远之哈儿)回复于 2003-12-02 11:27:35 得分 30

反正在现在的机子上,一律认为int   long   dword   的长度都32一般都没错的。呵呵,区别可以认为不存在。不过为了代码以后的可扩展性和兼容性,建议还是用DWORD,保险:)Top

12 楼ISunwu(刀口蒙特)回复于 2003-12-02 11:35:16 得分 0

MS这么用自然有它的道理。大家都遵循这个规则,就可以了。  
  谁叫我们是在他的基础上编码呢?Top

13 楼seilfer2000(郁闷,疯狂学习中)回复于 2003-12-02 11:48:55 得分 10

Data   Types  
  Value   Meaning    
  ATOM   Atom.   For   more   information,   see   Atoms.    
  BOOL   Boolean   variable   (should   be   TRUE   or   FALSE).    
  BOOLEAN   Boolean   variable   (should   be   TRUE   or   FALSE).    
  BYTE   Byte   (8   bits).    
  CALLBACK   Calling   convention   for   callback   functions.    
  CHAR   8-bit   Windows   (ANSI)   character.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  COLORREF   Red,   green,   blue   (RGB)   color   value   (32   bits).   See   COLORREF   for   information   on   this   type.    
  CONST   Variable   whose   value   is   to   remain   constant   during   execution.    
  CRITICAL_SECTION   Critical-section   object.   For   more   information,   see   Critical   Section   Objects.    
  DWORD   32-bit   unsigned   integer.    
  DWORD_PTR   Unsigned   long   type   for   pointer   precision.   Use   when   casting   a   pointer   to   a   long   type   to   perform   pointer   arithmetic.   (Also   commonly   used   for   general   32-bit   parameters   that   have   been   extended   to   64   bits   in   64-bit   Windows.   )    
  DWORD32   32-bit   unsigned   integer.    
  DWORD64   64-bit   unsigned   integer.    
  FLOAT   Floating-point   variable.    
  HACCEL   Handle   to   an   accelerator   table.    
  HANDLE   Handle   to   an   object.    
  HBITMAP   Handle   to   a   bitmap.      
  HBRUSH   Handle   to   a   brush.    
  HCONV   Handle   to   a   dynamic   data   exchange   (DDE)   conversation.    
  HCONVLIST   Handle   to   a   DDE   conversation   list.    
  HCURSOR   Handle   to   a   cursor.    
  HDC   Handle   to   a   device   context   (DC).    
  HDDEDATA   Handle   to   DDE   data.    
  HDESK   Handle   to   a   desktop.    
  HDROP   Handle   to   an   internal   drop   structure.    
  HDWP   Handle   to   a   deferred   window   position   structure.    
  HENHMETAFILE   Handle   to   an   enhanced   metafile.    
  HFILE   Handle   to   a   file   opened   by   OpenFile,   not   CreateFile.    
  HFONT   Handle   to   a   font.    
  HGDIOBJ   Handle   to   a   GDI   object.    
  HGLOBAL   Handle   to   a   global   memory   block.    
  HHOOK   Handle   to   a   hook.    
  HICON   Handle   to   an   icon.    
  HIMAGELIST   Handle   to   an   image   list.    
  HIMC   Handle   to   input   context.    
  HINSTANCE   Handle   to   an   instance.    
  HKEY   Handle   to   a   registry   key.    
  HKL   Input   locale   identifier.    
  HLOCAL   Handle   to   a   local   memory   block.    
  HMENU   Handle   to   a   menu.    
  HMETAFILE   Handle   to   a   metafile.    
  HMODULE   Handle   to   a   module.   The   value   is   the   base   address   of   the   module.    
  HMONITOR   Handle   to   a   display   monitor.    
  HPALETTE   Handle   to   a   palette.    
  HPEN   Handle   to   a   pen.      
  HRGN   Handle   to   a   region.    
  HRSRC   Handle   to   a   resource.    
  HSZ   Handle   to   a   DDE   string.    
  HWINSTA   Handle   to   a   window   station.    
  HWND   Handle   to   a   window.    
  INT   32-bit   signed   integer.    
  INT_PTR   Signed   integral   type   for   pointer   precision.   Use   when   casting   a   pointer   to   an   integer   to   perform   pointer   arithmetic.    
  INT32   32-bit   signed   integer.    
  INT64   64-bit   signed   integer.    
  LANGID   Language   identifier.   For   more   information,   see   Locales.    
  LCID   Locale   identifier.   For   more   information,   see   Locales.    
  LCTYPE   Locale   information   type.   For   a   list,   see   Locale   and   Language   Information.    
  LONG   32-bit   signed   integer.      
  LONG_PTR   Signed   long   type   for   pointer   precision.   Use   when   casting   a   pointer   to   a   long   to   perform   pointer   arithmetic.    
  LONG32   32-bit   signed   integer.    
  LONG64   64-bit   signed   integer.    
  LONGLONG   64-bit   signed   integer.    
  LPARAM   Message   parameter.    
  LPBOOL   Pointer   to   a   BOOL.      
  LPBYTE   Pointer   to   a   BYTE.      
  LPCOLORREF   Pointer   to   a   COLORREF   value.    
  LPCRITICAL_SECTION   Pointer   to   a   CRITICAL_SECTION.    
  LPCSTR   Pointer   to   a   constant   null-terminated   string   of   8-bit   Windows   (ANSI)   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  LPCTSTR   An   LPCWSTR   if   UNICODE   is   defined,   an   LPCTSTR   otherwise.    
  LPCVOID   Pointer   to   a   constant   of   any   type.    
  LPCWSTR   Pointer   to   a   constant   null-terminated   string   of   16-bit   Unicode   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  LPDWORD   Pointer   to   a   DWORD.    
  LPHANDLE   Pointer   to   a   HANDLE.    
  LPINT   Pointer   to   an   INT.    
  LPLONG   Pointer   to   a   LONG.    
  LPSTR   Pointer   to   a   null-terminated   string   of   8-bit   Windows   (ANSI)   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  LPTSTR   An   LPWSTR   if   UNICODE   is   defined,   an   LPSTR   otherwise.    
  LPVOID   Pointer   to   any   type.    
  LPWORD   Pointer   to   a   WORD.    
  LPWSTR   Pointer   to   a   null-terminated   string   of   16-bit   Unicode   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  LRESULT   Signed   result   of   message   processing.    
  LUID   Locally   unique   identifier.      
  PBOOL   Pointer   to   a   BOOL.    
  PBOOLEAN   Pointer   to   a   BOOL.    
  PBYTE   Pointer   to   a   BYTE.    
  PCHAR   Pointer   to   a   CHAR.    
  PCRITICAL_SECTION   Pointer   to   a   CRITICAL_SECTION.    
  PCSTR   Pointer   to   a   constant   null-terminated   string   of   8-bit   Windows   (ANSI)   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  PCTSTR   A   PCWSTR   if   UNICODE   is   defined,   a   PCSTR   otherwise.    
  PCWCH   Pointer   to   a   constant   WCHAR.    
  PCWSTR   Pointer   to   a   constant   null-terminated   string   of   16-bit   Unicode   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.      
  PDWORD   Pointer   to   a   DWORD.    
  PFLOAT   Pointer   to   a   FLOAT.    
  PHANDLE   Pointer   to   a   HANDLE.    
  PHKEY   Pointer   to   an   HKEY.    
  PINT   Pointer   to   an   INT.      
  PLCID   Pointer   to   an   LCID.    
  PLONG   Pointer   to   a   LONG.    
  PLUID   Pointer   to   a   LUID.      
  POINTER_32   32-bit   pointer.   On   a   32-bit   system,   this   is   a   native   pointer.   On   a   64-bit   system,   this   is   a   truncated   64-bit   pointer.      
  POINTER_64   64-bit   pointer.   On   a   64-bit   system,   this   is   a   native   pointer.   On   a   32-bit   system,   this   is   a   sign-extended   32-bit   pointer.    
  PSHORT   Pointer   to   a   SHORT.    
  PSTR   Pointer   to   a   null-terminated   string   of   8-bit   Windows   (ANSI)   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  PTBYTE   Pointer   to   a   TBYTE.    
  PTCHAR   Pointer   to   a   TCHAR.    
  PTSTR   PWSTR   if   UNICODE   is   defined,   a   PSTR   otherwise.    
  PTBYTE   Pointer   to   a   TBYTE.    
  PTCHAR   Pointer   to   a   TCHAR.    
  PTSTR   A   PWSTR   if   UNICODE   is   defined,   a   PSTR   otherwise.    
  PUCHAR   Pointer   to   a   UCHAR.    
  PUINT   Pointer   to   a   UINT.    
  PULONG   Pointer   to   a   ULONG.    
  PUSHORT   Pointer   to   a   USHORT.    
  PVOID   Pointer   to   any   type.    
  PWCHAR   Pointer   to   a   WCHAR.    
  PWORD   Pointer   to   a   WORD.    
  PWSTR   Pointer   to   a   null-terminated   string   of   16-bit   Unicode   characters.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  REGSAM   Security   access   mask   for   registry   key.    
  SC_HANDLE   Handle   to   a   service   control   manager   database.   For   more   information,   see   SCM   Handles.    
  SC_LOCK   Handle   to   a   service   control   manager   database   lock.   For   more   information,   see   SCM   Handles.    
  SERVICE_STATUS_HANDLE   Handle   to   a   service   status   value.   For   more   information,   see   SCM   Handles.    
  SHORT   Short   integer   (16   bits).    
  SIZE_T   The   maximum   number   of   bytes   to   which   a   pointer   can   point.   Use   for   a   count   that   must   span   the   full   range   of   a   pointer.    
  SSIZE_   T   Signed   SIZE_T.    
  TBYTE   A   WCHAR   if   UNICODE   is   defined,   a   CHAR   otherwise.    
  TCHAR   A   WCHAR   if   UNICODE   is   defined,   a   CHAR   otherwise.    
  UCHAR   Unsigned   CHAR.    
  UINT   Unsigned   INT.    
  UINT_PTR   Unsigned   INT_PTR.    
  UINT32   Unsigned   INT32.    
  UINT64   Unsigned   INT64.    
  ULONG   Unsigned   LONG.    
  ULONG_PTR   Unsigned   LONG_PTR.    
  ULONG32   Unsigned   LONG32.    
  ULONG64   Unsigned   LONG64.    
  ULONGLONG   64-bit   unsigned   integer.    
  UNSIGNED   Unsigned   attribute.    
  USHORT   Unsigned   SHORT.    
  VOID   Any   type.    
  WCHAR   16-bit   Unicode   character.   For   more   information,   see   Character   Sets   Used   By   Fonts.    
  WINAPI   Calling   convention   for   system   functions.    
  WORD   16-bit   unsigned   integer.    
  WPARAM   Message   parameter.    
   
  ___________________________________  
  DWORD   32-bit   unsigned   integer.    
  INT   32-bit   signed   integer.    
  上面是所有的类型看看就知道区别了  
  Top

相关问题

  • 数据库中的类型(CString和 CTime)和VC中的类型转换?
  • java中的byte类型在vc下可等同于什么数据类型
  • VC中数据类型定义中far的含义
  • vc中到底有多少数据类型
  • 在VC++6.0中支持数据类型string吗?
  • 弱弱的问:在VC 中如何变换数据类型?
  • vc++中的数据类型转换问题????
  • 请问Delphi中数据类型与VC中数据类型的对应和比较!
  • 如何在VC++中将long类型数据转换为string类型的数据(急)
  • VC的数据类型对应Delphi里的数据类型?

关键词

  • 32-bit
  • 指针
  • unicode
  • 数据
  • arithmetic
  • pointer
  • handles
  • bit
  • character
  • unsigned

得分解答快速导航

  • 帖主:sunjet2000
  • iicup
  • farfh
  • seilfer2000

相关链接

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

广告也精彩

反馈

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