COM co-class per-user registration

那年仲夏 提交于 2019-12-11 06:27:52

问题


Need to implement per-user registration of a COM co-class by adding registry entries to the HKCU registry hive (XP SP3, Windows 7, Windows 8). What is the minimal set of required registry entries to create an object instance by calling the VBScript CreateObject function?

UPD: VBScript implementation

Sub RegisterComObject(Path, ProgId, ClsId)
    Dim Shell
    Set Shell = WScript.CreateObject("WScript.Shell")

    Shell.RegWrite "HKCU\Software\Classes\" & ProgId & "\", ""
    Shell.RegWrite "HKCU\Software\Classes\" & ProgId & "\CLSID\", ClsId

    Shell.RegWrite "HKCU\Software\Classes\CLSID\" & ClsId & "\", ""
    Shell.RegWrite "HKCU\Software\Classes\CLSID\" & ClsId & "\InprocServer32\", Path
    Shell.RegWrite "HKCU\Software\Classes\CLSID\" & ClsId & "\ProgID\", ProgID
End Sub

Sub UnregisterComObject(ProgId, ClsId)
    Dim Shell
    Set Shell = WScript.CreateObject("WScript.Shell")

    Shell.RegDelete "HKCU\Software\Classes\CLSID\" & ClsId & "\InprocServer32\"
    Shell.RegDelete "HKCU\Software\Classes\CLSID\" & ClsId & "\ProgId\"
    Shell.RegDelete "HKCU\Software\Classes\CLSID\" & ClsId & "\"

    Shell.RegDelete "HKCU\Software\Classes\" & ProgId & "\CLSID\"
    Shell.RegDelete "HKCU\Software\Classes\" & ProgId & "\"
End Sub

回答1:


You need:

  1. HKEY_CURRENT_USER\Software\Classes\CLSID\{your-CLSID-goes-here} branch with subkey InprocServer32 (or, LocalServer32) with its regular syntax
  2. HKEY_CURRENT_USER\Software\Classes\{your-ProgID-goes-here} to map your ProgID to CLSID in order for CreateObject to succeed.


来源:https://stackoverflow.com/questions/20782059/com-co-class-per-user-registration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!