Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:04:26+00:00 2026-06-12T10:04:26+00:00

The code below, compiled under Delphi XE2 Win32 and running under Win 7 64

  • 0

The code below, compiled under Delphi XE2 Win32 and running under Win 7 64 bit, produces the following exception when executing the line “AudioSessionManager2.GetSessionEnumerator”:

“Project22.exe raised exception class $C0000005 with message ‘access violation at 0x7027edb2: write of address 0x0051ced6′”

My knowledge of exception classes or what they mean is lacking, so I have no idea as to what the exception means or how to go about fixing it.

Here is the code that raises the exception (asserts used to debug code):

var
  HRES: HRESULT;
  DeviceEnumerator: IMMDeviceEnumerator;
  DefaultDevice: IMMDevice;
  AudioSessionManager2: IAudioSessionManager2;
  Enumerator: IAudioSessionEnumerator;
begin

  CoInitialize( nil );

  HRES := CoCreateInstance( CLSID_MMDeviceEnumerator, nil, CLSCTX_ALL, IID_IMMDeviceEnumerator, DeviceEnumerator );
  Assert( Succeeded( HRES ) );

  HRES := DeviceEnumerator.GetDefaultAudioEndpoint( eRender, eMultimedia, DefaultDevice );
  Assert( Succeeded( HRES ) );

  HRES := DefaultDevice.Activate( IID_IAudioSessionManager2, CLSCTX_ALL, nil, IUnknown( AudioSessionManager2 ) );
  Assert( Succeeded( HRES ) );

  HRES := AudioSessionManager2.GetSessionEnumerator( Enumerator );  // <- EXCEPTION HERE
  Assert( Succeeded( HRES ) );

  [snip]

I’m using the Core Audio definitions from MFPack on Google Code, with the IAudioSessionManager2 and IAudioSessionEnumerator interfaces looking as follow:

IAudioSessionManager2 = interface(IUnknown)
['{77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F}']
  function GetSessionEnumerator(out SessionEnum: IAudioSessionEnumerator): HResult; stdcall;
  function RegisterSessionNotification(SessionNotification: IAudioSessionNotification): HResult; stdcall;
  function UnregisterSessionNotification(SessionNotification: IAudioSessionNotification): HResult; stdcall;
  function RegisterDuckNotification(const sessionID: LPCWSTR; const duckNotification: IAudioVolumeDuckNotification): HResult; stdcall;
  function UnregisterDuckNotification(const duckNotification: IAudioVolumeDuckNotification): HResult; stdcall;
end;

IAudioSessionEnumerator = interface(IUnknown)
['{E2F5BB11-0570-40CA-ACDD-3AA01277DEE8}']
  function GetCount(out SessionCount: integer): HResult; stdcall;
  function GetSession(const SessionCount: integer; out Session: IAudioSessionControl): HResult; stdcall;
end;

I believe the interfaces are properly defined and I also double-checked the GUIDs.

Since the same sequence of instructions execute as intended under Visual Studio 2012 (Win32 project), I suspect the problem is with my code (little doubt here), the Core Audio interfaces definitions or Delphi. The C++ code running in VS is the following:

IMMDeviceEnumerator *DeviceEnumerator = NULL;
IMMDevice* DefaultDevice = NULL;
IAudioSessionManager2* AudioSessionManager = NULL;
IAudioSessionEnumerator* Enumerator = NULL;
HRESULT HR;

HR = CoCreateInstance( __uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&DeviceEnumerator );
HR = DeviceEnumerator->GetDefaultAudioEndpoint( eRender, eMultimedia, &DefaultDevice );
HR = DefaultDevice->Activate( __uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL,(void**)&AudioSessionManager );
HR = AudioSessionManager->GetSessionEnumerator( &Enumerator );

With the C++ code I can retrieve the session enumerator correctly and use GetCount, etc.

I spent countless hours trying to find out what was wrong with my code and I’m still clueless, so any help would greatly be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:04:27+00:00Added an answer on June 12, 2026 at 10:04 am

    According to MSDN, IAudioSessionManager2 should inherit from IAudioSessionManager:

    type
      IAudioSessionManager2 = interface(IAudioSessionManager)
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming that: The C# source code below is compiled under .NET 2.0 (CLR 2.0);
I want some code tobe compiled under 10.6 and below but not 10.7 and
The code below compiled in Debug configuration in VS2005 SP1 shows two messages with
It is a compiler error or runtime error? The code below can be compiled!
Attempting to compile the following code under Qt SDK 4.7.4 for Desktop - MinGW
I have a doubt on basic C++ usage. The code below, compiled with gcc/LInux,
[Replaced code by a complete program and versions update] The code below fails under
This is a bit puzzling here. The following code is part of a little
I've found this odd case of some code (below) doesn't compile under Visual Studio
The code below is compiled from CoffeeScript, hope it's still readable (function() { $(function()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.