JanDeDobbeleer/oh-my-posh · error

RoGetActivationFactory: 0x%08x

Error message

RoGetActivationFactory: 0x%08x

What it means

After building the class HSTRING, the SMTC code activates the GlobalSystemMediaTransportControlsSessionManager statics via RoGetActivationFactory. A non-zero HRESULT means the activation factory could not be obtained - the class is not available, the runtime is not usable, or activation failed - and no media session information can be retrieved.

Source

Thrown at src/runtime/smtc_windows.go:246

	if hr != 0 && hr != 1 {
		return nil, fmt.Errorf("RoInitialize: 0x%08x", hr)
	}
	defer func() { _, _, _ = procRoUninitialize.Call() }()

	classID, err := newHString("Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager")
	if err != nil {
		return nil, err
	}
	defer classID.Close()

	var factory unsafe.Pointer
	hr, _, _ = procRoGetActivationFactory.Call(
		uintptr(classID),
		uintptr(unsafe.Pointer(&iidSMTCSessionManagerStatics)),
		uintptr(unsafe.Pointer(&factory)),
	)
	if hr != 0 {
		return nil, fmt.Errorf("RoGetActivationFactory: 0x%08x", hr)
	}
	defer comRelease(factory)

	var asyncOp unsafe.Pointer
	if hr := comCall(factory, staticsRequestAsync, uintptr(unsafe.Pointer(&asyncOp))); hr != 0 {
		return nil, fmt.Errorf("RequestAsync: 0x%08x", hr)
	}
	defer comRelease(asyncOp)

	if err := awaitAsync(asyncOp); err != nil {
		return nil, fmt.Errorf("await RequestAsync: %w", err)
	}

	var manager unsafe.Pointer
	if hr := comCall(asyncOp, asyncOpGetResults, uintptr(unsafe.Pointer(&manager))); hr != 0 {
		return nil, fmt.Errorf("GetResults manager: 0x%08x", hr)
	}
	defer comRelease(manager)

View on GitHub (pinned to 0976794618)

Solutions

  1. Upgrade to Windows 10 1809+ where the SMTC SessionManager API exists
  2. Install the Media Feature Pack on Windows N/KN editions
  3. Verify media playback is available in the session (no SMTC sessions on headless/serviced contexts) - the segment simply cannot work there
  4. Decode the HRESULT in the message (e.g. 0x80040154 = class not registered) to pinpoint whether it is a missing-API vs initialization problem
  5. Ensure nothing in the environment blocked COM initialization (see the preceding RoInitialize error)
Defensive patterns

Strategy: fallback

Validate before calling

func smtcAvailable() bool {
	if !windowsRuntimeSupported() { return false } // Win10 1809+, non-N editions
	return true
}
// gate the media segment on this before calling QueryMediaPlayer

Try / catch

info, err := runtime.QueryMediaPlayer(env)
if err != nil {
	// 0x80040154 => class not registered: SMTC unavailable, hide segment
	log.Debugf("media segment disabled: %v", err)
	return mediaSegment{}
}

Prevention

When it happens

Trigger: QueryMediaPlayer calling RoGetActivationFactory for Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager and receiving an error such as REGDB_E_CLASSNOTREG (0x80040154, class not registered), E_NOINTERFACE, or CO_E_NOTINITIALIZED.

Common situations: Windows versions before 10.0.17763 / Windows 10 1809 where the SMTC SessionManager class does not exist; Windows N/KN editions lacking media features; running in environments (some services, stripped containers) where the WinRT media stack is unavailable; RoInitialize having failed earlier in the chain.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/b119a0c7c874c036. Report an issue: GitHub.