关于ATL的rgs注册文件
转自:http://blog.csdn.net/idiszerg/article/details/3875934
使用ATL向导的话,会在resource中产生一个rgs的注册脚本文件放在"REGISTRY"目录中用来注册组件,会在程序中通过函数DECLARE_REGISTRY_RESOURCEID(IDR_OPCSERVER)使用,IDR_OPCSERVER就是向导产生的资源文件的ID,当服务器调用CComModule::RegisterServer()时,便会使用这些脚本来载入注册表的设置,并在调用CComModule::UnregisterServer()时移除它们。所有COM的注册键都放在HKEY_CLASSES_ROOT中。
例子如下
HKCR
{
FactorySoft.myShell.1 = s 'FactorySoft myShell'
{
CLSID = s '{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}'
}
FactorySoft.myShell = s 'FactorySoft myShell'
{
CLSID = s '{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}'
OPC
{
Vendor = s 'FactorySoft, Inc'
}
}
NoRemove CLSID
{
ForceRemove {C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F} = s 'FactorySoft myShell'
{
ProgID = s 'FactorySoft.myShell.1'
VersionIndependentProgID = s 'FactorySoft.myShell'
LocalServer32 = s '%MODULE%'
{
val ThreadingModel = s 'both'
}
}
}
NoRemove AppID
{
ForceRemove {C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F} = s 'FactorySoft myShell'
}
}
HKCR 表示注册表中COM对象的注册项是HKEY_CLASS_ROOT 的缩写
NoRemove表示在反注册过程中不要删除这层注册表项;ForceRemove表示要要完全删除后面的项然后重新创建。MSDN原文如下
String Literal | Description |
ForceRemove | Completely remove the following key (if it exists) and then recreate it. |
NoRemove | Do not remove the following key during Unregister. |
val | The following <Key Name> is actually a named value. |
Delete | Delete the following key during Register. |
s | The following value is a string. |
d | The following value is a DWORD. |
注册后的注册表主要修改如下
1、HKEY_CLASSES_ROOT/AppID/
[HKEY_CLASSES_ROOT/AppID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}]
@="FactorySoft myShell"
2、HKEY_CLASSES_ROOT/CLSID/
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}]
@="FactorySoft myShell"
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories]
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories/{63D5F430-CFE4-11D1-B2C8-0060083BA1FB}]
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories/{63D5F432-CFE4-11D1-B2C8-0060083BA1FB}]
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/LocalServer32]
@="D://temp//test//Debug//myShell.exe"
"ThreadingModel"="both"
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/ProgID]
@="FactorySoft.myShell.1"
[HKEY_CLASSES_ROOT/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/VersionIndependentProgID]
@="FactorySoft.myShell"
3、HKEY_CLASSES_ROOT/FactorySoft.myShell
[HKEY_CLASSES_ROOT/FactorySoft.myShell]
@="FactorySoft myShell"
[HKEY_CLASSES_ROOT/FactorySoft.myShell/CLSID]
@="{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}"
[HKEY_CLASSES_ROOT/FactorySoft.myShell/OPC]
[HKEY_CLASSES_ROOT/FactorySoft.myShell/OPC/Vendor]
@="FactorySoft, Inc"
[HKEY_CLASSES_ROOT/FactorySoft.myShell.1]
@="FactorySoft myShell"
[HKEY_CLASSES_ROOT/FactorySoft.myShell.1/CLSID]
@="{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}"
4、HKEY_LOCAL_MACHINE/SOFTWARE/Classes/AppID
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/AppID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}]
@="FactorySoft myShell"
5、HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}]
@="FactorySoft myShell"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories]
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories/{63D5F430-CFE4-11D1-B2C8-0060083BA1FB}]
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/Implemented Categories/{63D5F432-CFE4-11D1-B2C8-0060083BA1FB}]
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/LocalServer32]
@="D://temp//test//Debug//myShell.exe"
"ThreadingModel"="both"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/ProgID]
@="FactorySoft.myShell.1"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}/VersionIndependentProgID]
@="FactorySoft.myShell"
6、HKEY_LOCAL_MACHINE/SOFTWARE/Classes/
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell]
@="FactorySoft myShell"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell/CLSID]
@="{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell/OPC]
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell/OPC/Vendor]
@="FactorySoft, Inc"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell.1]
@="FactorySoft myShell"
[HKEY_LOCAL_MACHINE/SOFTWARE/Classes/FactorySoft.myShell.1/CLSID]
@="{C9B70C6C-2BEE-4589-96B3-01E2F4D21C9F}"
从中可以看出s '%MODULE%'被替换成了@="D://temp//test//Debug//myShell.exe"程序的路径