WIN32 API之硬件控制
2006-09-01 17:46
267 查看
一、Beep
The Beep function generates(产生) simple tones(音调) on the speaker. The function is synchronous(同步的); it does not return control to its caller until the sound finishes.
BOOL Beep(
DWORD dwFreq, // sound frequency
DWORD dwDuration // sound duration
);
Parameters
dwFreq
Windows NT/ 2000: [in] Specifies(指定) the frequency(频率), in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration
Windows NT/ 2000: [in] Specifies the duration(持续时间), in milliseconds, of the sound.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep
Samples:
void CAboutDlg::OnButton1()
{
// TODO: Add your control notification handler code here
// Beep 用于生成简单的声音
Beep(1000,1); // 发一次1000频率的声音
}
二、ClipCursor(CONST RECT *lpRect)、GetClipCursor(LPRECT lpRect)
设置鼠标活动范围,取得鼠标活动范围。
Samples:
void CAboutDlg::OnButton1()
{
// TODO: Add your control notification handler code here
// ActivateKeyboardLayout 激活一个新的键盘布局。键盘布局定义了按键在一种物理性键盘上的位置与含义
RECT rt;
rt.left = 30;
rt.right = 300;
rt.top = 20;
rt.bottom = 200;
ClipCursor(&rt); // 你的光标只能在固定区域啦。
GetClipCursor(LPRECT lpRect)
}
void CAboutDlg::OnButton2()
{
// TODO: Add your control notification handler code here
RECT rt;
GetClipCursor(&rt);
CString str;
str.Format(TEXT("Cursor is in right = %d buttom = %d"),rt.right,rt.bottom );
MessageBox(str);
}
建议先调用GetClipCursor()将用户默认的鼠标活动范围取出到全局变量中。之后调用ClipCursor()设置鼠标活动范围。最后再调用一次ClipCursor()恢复用户默认的鼠标活动范围。
The Beep function generates(产生) simple tones(音调) on the speaker. The function is synchronous(同步的); it does not return control to its caller until the sound finishes.
BOOL Beep(
DWORD dwFreq, // sound frequency
DWORD dwDuration // sound duration
);
Parameters
dwFreq
Windows NT/ 2000: [in] Specifies(指定) the frequency(频率), in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration
Windows NT/ 2000: [in] Specifies the duration(持续时间), in milliseconds, of the sound.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep
Samples:
void CAboutDlg::OnButton1()
{
// TODO: Add your control notification handler code here
// Beep 用于生成简单的声音
Beep(1000,1); // 发一次1000频率的声音
}
二、ClipCursor(CONST RECT *lpRect)、GetClipCursor(LPRECT lpRect)
设置鼠标活动范围,取得鼠标活动范围。
Samples:
void CAboutDlg::OnButton1()
{
// TODO: Add your control notification handler code here
// ActivateKeyboardLayout 激活一个新的键盘布局。键盘布局定义了按键在一种物理性键盘上的位置与含义
RECT rt;
rt.left = 30;
rt.right = 300;
rt.top = 20;
rt.bottom = 200;
ClipCursor(&rt); // 你的光标只能在固定区域啦。
GetClipCursor(LPRECT lpRect)
}
void CAboutDlg::OnButton2()
{
// TODO: Add your control notification handler code here
RECT rt;
GetClipCursor(&rt);
CString str;
str.Format(TEXT("Cursor is in right = %d buttom = %d"),rt.right,rt.bottom );
MessageBox(str);
}
建议先调用GetClipCursor()将用户默认的鼠标活动范围取出到全局变量中。之后调用ClipCursor()设置鼠标活动范围。最后再调用一次ClipCursor()恢复用户默认的鼠标活动范围。
相关文章推荐
- 通过API实现C#对硬件的控制(一)
- VisualC++利用CRegKey和WIN32 API获取系统硬件信息
- [Win32] SCManager 服务控制管理器API(2)
- 通过API实现C#对硬件的控制(二)
- 非标准硬件控制之增加系统API
- VisualC++利用CRegKey和WIN32 API获取系统硬件信息
- Hook Win32 API 的应用研究之三:变速控制
- 转发 C# Win32 API程序控制鼠标的操作
- C#+Win32 API程序控制鼠标的操作
- Win32 API进程创建控制
- 通过API实现C#对硬件的控制(一)
- 通过API实现C#对硬件的控制(一)
- 通过API实现C#对硬件的控制(一)
- Java学习笔记 Java调用Win32 API控制鼠标活动范围
- 通过API实现C#对硬件的控制(一)
- 【转】[C#.NET][VB.NET] 用 Win32 API 控制 外部應用程式選單
- 通过API实现C#对硬件的控制(一)
- C#+Win32 API程序控制鼠标的操作 解脱烦重的鼠标繁复操作
- 通过API实现C#对硬件的控制(二)
- 通过API实现C#对硬件的控制(一)