一、regsvr32的时候要以管理员的身份运行
二、我写COM组件的时候通过DllRegisterServer注册时候找不到注册成功但找不到CLSID,其实是找错地方了,我写的是一个32位的COM,在64位的电脑上注册CLSID。
long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT,
szKeyBuf,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS , NULL,
&hKey, NULL);
这样写代码,会把CLSID注册到
计算机\HKEY_CLASSES_ROOT\WOW6432Node\CLSID{54BF6567-1007-11D1-B0AA-444553540000}里面去
三、要是想注册到64位的registry必须这样写
改成 long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT,
szKeyBuf,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL,
&hKey, NULL);
加上 KEY_WOW64_64KEY才能在计算机\HKEY_CLASSES_ROOT\CLSID{54BF6567-1007-11D1-B0AA-444553540000}查到注册消息
KEY_WOW64_32KEY (0x0200)
Indicates that an application on 64-bit Windows should operate on the 32-bit registry view. This flag is ignored by 32-bit Windows. For more information, see Accessing an Alternate Registry View.
This flag must be combined using the OR operator with the other flags in this table that either query or access registry values.
Windows 2000: This flag is not supported.
KEY_WOW64_64KEY (0x0100)
Indicates that an application on 64-bit Windows should operate on the 64-bit registry view. This flag is ignored by 32-bit Windows. For more information, see Accessing an Alternate Registry View.
This flag must be combined using the OR operator with the other flags in this table that either query or access registry values.
Windows 2000: This flag is not supported.
四、下面的函数也要作出相应的考虑,要用Ex版本上KEY_WOW64_64KEY
RegOpenKeyEx(hKeyParent, lpszKeyChild, 0, KEY_ALL_ACCESS | KEY_WOW64_64KEY, &hKeyChild);
RegDeleteKeyEx(hKeyParent, lpszKeyChild, KEY_WOW64_64KEY, 0);
五、再整理一遍写到32位registry上需要用到的函数
RegCreateKeyEx(HKEY_CLASSES_ROOT,
szKeyBuf,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS /*| KEY_WOW64_64KEY*/, NULL,
&hKey, NULL);
RegOpenKeyEx(hKeyParent, lpszKeyChild, 0, KEY_ALL_ACCESS /*| KEY_WOW64_64KEY*/, &hKeyChild);
RegDeleteKey(hKeyParent, lpszKeyChild);
六、测试COM的程序是32位的也许他是回去32位的目录下找COM
hResult = CoCreateInstance(dictionaryCLSID, NULL,
CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnknown);
要是没有注册到32位的registry创建对象会报错。