未分类--Windows API--CreateHardwareEventMoniker

来源:互联网 发布:淘宝手机店招图片 编辑:程序博客网 时间:2024/05/02 02:32

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件643166601@qq.com

 

CreateHardwareEventMoniker Function

--------------------------------------------------------------------------------

Creates a moniker representing a hardware component and its associated event handler.
创建一个标记表示一个硬件组件和它关联的事件句柄。
AutoPlay uses this function to allow applications to use AutoPlay events.
自动播放使用这个函数,它允许应用程序去使用自动播放事件。
Syntax

HRESULT CreateHardwareEventMoniker(         
REFCLSID clsid,
LPCTSTR pszEventHandler,
IMoniker **ppmoniker
);
Parameters

clsid
[in] The ID of the class to which the moniker binds.
类的这个ID是标记绑定。
pszEventHandler
[in] The name of the event handler.
事件句柄的名称。
ppmoniker
[out] The address of a pointer variable that receives the IMoniker interface pointer.
一个指针变量的地址它接收IMoniker接口指针。
Return Value

Returns S_OK if successful, or an error value otherwise.
如果成功返回S_OK,否则一个错误值。
Remarks

Note  This function is available through Microsoft Windows XP Service Pack 2 (SP2) and Windows Server 2003.
注意:这个函数是可用的在Microsoft Windows XP Service Pack 2 (SP2) 和Windows Server 2003中。
It might be altered or unavailable in subsequent versions of Windows.
它可能被修改或不可用在Windows的随后版本中
Use CreateHardwareEventMoniker when registering running applications so that those applications have access to AutoPlay events.
当注册运行程序时使用CreateHardwareEventMoniker以致于这些应用程序可以访问自动播放事件。
To use AutoPlay events in running applications, you must first create a new component that implements the IHWEventHandler interface.
在运行的程序中去使用自动播放事件,你必须首先创建一个新的组件它实现IHWEventHandler接口。
Initialize this interface with the InitCmdLine value from the particular handler's entry under the Handlers key, because AutoPlay does not call the Initialize method.
初始化这个接口用InitCmdLine的值从特定的句柄的入口在这个句柄键下,因为自动播放不调用Initialize方法。
You should call CreateHardwareEventMoniker to get a moniker that represents your component and its event handler.
你应该调用CreateHardwareEventMoniker去获得一个标记,她代表你的组件和它的事件句柄。
Then, use the value returned in the ppmoniker parameter to register your component in the running object table (ROT) as shown in the example.
然后,在ppmoniker参数中使用返回值去注册你运行对象表(ROT)组件在例子中给予展示。
Note that CreateHardwareEventMoniker is not defined in a header file.
注意CreateHardwareEventMoniker没有在头文件中定义。
To use it in your code, you must obtain a handle to the Shsvcs.dll file through a call to LoadLibrary.
在你的代码中去使用它,你必须通过调用LoadLibrary包含一个句柄到Shsvcs.dll文件。
You then use that handle in a call to GetProcAddress to obtain an instance of the CreateHardwareEventMoniker function.
你然后使用句柄调用GetProcAddress去包含一个CreateHardwareEventMoniker函数的实例。
The call to IRunningObjectTable::Register requires that you enter the following AppID information in the registry.
这个调用到IRunningObjectTable::Register请求,你在注册表中输入以下AppID信息。
HKEY_CLASSES_ROOT
AppID
MyApp.exe
(Default) = MyApplication
AppID [REG_SZ] = {Your GUID here}
HKEY_CLASSES_ROOT
AppID
{The same GUID here}
(Default) = MyApplication
RunAs = Interactive User

Function Information

Minimum DLL Version Shsvcs.dll
Custom Implementation No
Import library None
Minimum operating systems Windows XP

 

0 0