VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 577|回复: 1

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

[复制链接]
38_avatar_middle
online_vip 发表于 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 发表于 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

本版积分规则

关闭

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

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

GMT+8, 2019-7-17 13:33

Powered by Discuz! X3.4

© 2009-2019 cctry.com

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