VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

有编程疑问吗?还请到提问专区发帖提问!
搜索
查看: 427|回复: 1

[求助] windows自定义的类型后缀 _PTR作用

[复制链接]
38_avatar_middle
online_vip 2191265529 发表于 2018-4-13 20:25:26 | 显示全部楼层 |阅读模式
3驿站币
比如UINT_PTR这个名字有什么来头吗

最佳答案

查看完整内容

原文详见:https://stackoverflow.com/questions/1271748/dword-ptr-int-ptr-long-ptr-uint-ptr-ulong-ptr-when-how-and-why The *_PTR types were added to the Windows API in order to support Win64's 64bit addressing. Because 32bit APIs typically passed pointers using data types like DWORD, it was necessary to create new types for 64 bit compatibility that could substitute for DWORD in 32bit applicat ...




上一篇:链表
下一篇:The ActiveX contrl is not registered on this computer

发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

如果你已经在论坛发帖求助,并且从坛友或者管理的回复中解决了问题,请编辑帖子并把分类改成【已解决】

如何回报帮助你解决问题的坛友?可以给对方加【热心】【驿站币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

51_avatar_middle
online_admins Syc 发表于 2018-4-13 20:25:27 | 显示全部楼层
原文详见:https://stackoverflow.com/questi ... tr-when-how-and-why

The *_PTR types were added to the Windows API in order to support Win64's 64bit addressing.

Because 32bit APIs typically passed pointers using data types like DWORD, it was necessary to create new types for 64 bit compatibility that could substitute for DWORD in 32bit applications, but were extended to 64bits when used in a 64bit applications.

So, for example, application developers who want to write code that works as 32bit OR 64bit the windows 32bit API SetWindowLong(HWND,int,LONG) was changed to SetWindowLongPtr(HWND,int,LONG_PTR)

In a 32bit build, SetWindowLongPtr is simply a macro that resolves to SetWindowLong, and LONG_PTR is likewise a macro that resolves to LONG. In a 64bit build on the other hand, SetWindowLongPtr is an API that accepts a 64bit long as its 3rd parameter, and ULONG_PTR is typedef for unsigned __int64.

By using these _PTR types, one codebase can compile for both Win32 and Win64 targets.

评分

参与人数 1驿站币 +2 热心值 +2 收起 理由
38_avatar_small 2191265529 + 2 + 2 极度给力!

查看全部评分

发帖求助前要善用论坛搜索功能,那里可能会有你要找的答案;

如果你已经在论坛发帖求助,并且从坛友或者管理的回复中解决了问题,请编辑帖子并把分类改成【已解决】

如何回报帮助你解决问题的坛友?可以给对方加【热心】【驿站币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

关闭

站长提醒上一条 /1 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号 )|网站地图wx_jqr

GMT+8, 2018-11-19 22:37

Powered by Discuz! X3.4

© 2009-2018 cctry.com

快速回复 返回顶部 返回列表