Announcement

Collapse
No announcement yet.

Register more entries during regsvr32?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Edwin Knoppert
    replied
    Oh thanks, instead of pb inserts the functions, i will
    I'll check out later.

    Leave a comment:


  • Dominic Mitchell
    replied
    Just have your PB COM server export the DllRegisterServer function. It will also have to export
    the DllUnregisterServer function to remove the registry entries.
    For example, to add registry keys for a Browser Helper Object via regsvr32, one would use
    code similar to the following:
    Code:
    FUNCTION DllRegisterServer ALIAS "DllRegisterServer" () EXPORT AS LONG
    
      LOCAL szModule    AS ASCIIZ * 1024
      LOCAL szValue     AS ASCIIZ * 2048
      LOCAL szKey       AS ASCIIZ * %MAX_PATH
      LOCAL szKey2      AS ASCIIZ * %MAX_PATH
      LOCAL lpwsz       AS DWORD
      LOCAL cbBuf       AS DWORD
      LOCAL pITypeLib   AS DWORD
      LOCAL hr          AS LONG
    
      ' Obtain the path to this module's executable file for later use.
      GetModuleFileName ghInstance, szModule, SIZEOF(szModule)
    
      ' CLSID key
      ' ---------
      ' Build the key CLSID\{...}
      szKey = "CLSID\"
      lstrcat szKey, GUIDTXT$($CLSID_BHOPB)
    
    	' Add the CLSID to the registry.
      szValue = "BHO"
      SHSetValue %HKEY_CLASSES_ROOT, szKey, BYVAL %NULL, %REG_SZ, BYVAL VARPTR(szValue), LEN(szValue)
    
    	' Add the server filename subkey under the CLSID key.
      SHSetValue %HKEY_CLASSES_ROOT, szKey + "\InprocServer32", BYVAL %NULL, %REG_SZ, BYVAL VARPTR(szModule), LEN(szModule)
    
      ' Add the named value, Threading model, to the InprocServer32 subkey.
      szValue = "Apartment"
      SHSetValue %HKEY_CLASSES_ROOT, szKey + "\InprocServer32", "ThreadingModel", %REG_SZ, BYVAL VARPTR(szValue), LEN(szValue)
    
      ' Add the Typelib subkey under the CLSID key.
      szValue = GUIDTXT$($LIBID_BHOPB)
      SHSetValue %HKEY_CLASSES_ROOT, szKey + "\TypeLib", BYVAL %NULL, %REG_SZ, BYVAL VARPTR(szValue), LEN(szValue)
    
      ' Add the Version subkey under the CLSID key.
      szValue = "1.0"
      SHSetValue %HKEY_CLASSES_ROOT, szKey + "\Version", BYVAL %NULL, %REG_SZ, BYVAL VARPTR(szValue), LEN(szValue)
    
      ' Register as a BHO
      szKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\"
      lstrcat szKey, GUIDTXT$($CLSID_BHOPB)
      SHSetValue %HKEY_LOCAL_MACHINE, szKey, BYVAL %NULL, %REG_SZ, BYVAL %NULL, 0
    
      ' Register as a dowload manager
      szKey = "SOFTWARE\Microsoft\Internet Explorer\"
      szValue = GUIDTXT$($CLSID_BHOPB)
      SHSetValue %HKEY_LOCAL_MACHINE, szKey, "DownloadUI", %REG_SZ, BYVAL VARPTR(szValue), LEN(szValue)
    
      ' Register the type library
      cbBuf = LEN(szModule) + 1
      lpwsz = CoTaskMemAlloc(cbBuf + cbBuf)
      IF lpwsz THEN
        ZeroMemoryEx lpwsz, cbBuf + cbBuf
        MultiByteToWideChar %CP_ACP, 0, BYVAL VARPTR(szModule), -1, BYVAL lpwsz, cbBuf
        hr = LoadTypeLib(lpwsz, pITypeLib)
        IF hr = %S_OK THEN
          hr = RegisterTypeLib(pITypeLib, lpwsz, lpwsz)
          IUnknown_Release pITypeLib
        END IF
        CoTaskMemFree lpwsz
      END IF
    
      FUNCTION = %S_OK
      	
    END FUNCTION

    Leave a comment:


  • Edwin Knoppert
    started a topic Register more entries during regsvr32?

    Register more entries during regsvr32?

    In .NET it is possible to get notified during the registration of the com server like:
    Code:
     [ComRegisterFunctionAttribute]
            public static void RegisterFunction(Type type)
            {
                Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type, "Programmable"));
                RegistryKey key = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"), true);
                key.SetValue("", System.Environment.SystemDirectory + @"\mscoree.dll", RegistryValueKind.String);
            }
    Can this be done with the PB classes?
Working...
X