什么LRESULT,wParam和lParam是什么意思? [英] What do LRESULT, WPARAM and LPARAM mean?
问题描述
我进口WINAPI功能,写回调等(的例如)在C#中,总是在想:
I'm importing WinApi functions, writing callbacks etc. (example) in C# and always wonder:
- 请他们是什么意思?
LRESULT
为最后的结果的? W-PARAM? L-PARAM? - 如何安全地包装他们的
-
WPARAM
和LPARAM
包含结构的时候。所以,我需要把它们作为的IntPtr
。如何LRESULT
?我是安全与INT
或更好的IntPtr
?
- what do they mean ?
LRESULT
as last result ? W-PARAM ? L-PARAM ? - how to safely "wrap" them
WPARAM
andLPARAM
contain structs sometimes. So I need to use them asIntPtr
. How aboutLRESULT
? Am I safe withint
or betterIntPtr
?
我使用什么类型的在C#中LRESULT?
INT
或的IntPtr
推荐答案
这是查尔斯·西蒙尼,应用软件组的前负责人微软是开发Word和Excel的组。他这么集标识符命名标准之一。因为没有人知道如何发音他的姓氏,他们选他出生在该国并称之为匈牙利命名法。 Windows组通过了为好,但选择了不好之类的,系统的匈牙利。凡标识符的第一个字母(S)选择要注意的键入的变量。相对于好的那种,应用匈牙利,它选择了逻辑类型名称,而不是物理类型名称的前缀。西蒙尼的版本。
That's Charles Simonyi, the former head of the Application Software group at Microsoft, the group that developed Word and Excel. He's the one that set identifier naming standards. Since nobody knows how to pronounce his last name, they picked the country he was born in and called it Hungarian notation. The Windows group adopted it as well, but picked the "bad" kind, System Hungarian. Where the first letter(s) of the identifier is chosen to note the type of the variable. As opposed to the "good" kind, Apps Hungarian, which selects the prefix by the logical type name instead of the physical type name. Simonyi's version.
因此,它是L,以在龙,W如在Word中。 LPCWSTR就是这样一个想睡,长指针,恒宽字符串。与匈牙利系统一个明确的问题是,它不工作这么好了架构更改时。最初钦点为16位操作系统(L = 32位,W = 16位),迁移到32位而不更改名称(W = 32位)的今天,我们在64位(L = W = 64位)。
So it is L as in Long, W as in Word. LPCWSTR is a dozy like that, Long Pointer to Constant Wide String. A clear problem with System Hungarian is that it doesn't work so well anymore when the architecture changes. Originally picked for 16-bit operating systems (L=32-bits, W=16-bits), migrated to 32-bit without changing the name (W=32-bits), we're at 64-bit today (L=W=64-bits).
所以忽略这些前缀,他们只是历史的偶然。你真的必须挑的IntPtr为LRESULT类型,它肯定可以在Windows的64位版本的64位值。很辛苦的时候你不在出现诊断问题,在这里一个常见的问题。
So ignore these prefixes, they're just an historical accident. You really must pick IntPtr for the LRESULT type, it certainly can be a 64-bit value on the 64-bit version of Windows. Very hard to diagnose problems occur when you don't, a common question here.
题外话,你在照片的背景看模糊的图像是一个有趣的珍闻有关西蒙尼为好。微软分享了巨大的成功与员工并把许多人成为百万,千万富翁。你在后台看到的是停靠在国际空间站的航天飞机的一个镜头。西蒙尼是七太空游客之一,他自己买了票到IIS。唯一一个这样做的两次的,设置他回$ 60万:)
Off topic, the fuzzy image you see in the background of the photograph is an interesting tidbit about Simonyi as well. Microsoft shared its great success with its employees and turned many of them into multi-millionaires. What you see in the background is a shot of the space shuttle docked to the International Space Station. Simonyi is one of the seven "space tourists" and bought himself a ticket to the IIS. The only one to do so twice, set him back $60 million :)
这篇关于什么LRESULT,wParam和lParam是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-