Results 1 to 1 of 1

Thread: [Question] Calling COM+ (MMDeviceEnumerator and IAudioMeterInformation)

  1. #1
    Join Date
    Jun 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default [Question] Calling COM+ (MMDeviceEnumerator and IAudioMeterInformation)

    Hello. Im trying to interface the MMDeviceEnumerator COM.
    I've developed a Wrapper class for that interface in VB6 (source is here), and now im trying to get it working in QT.
    Now im debugging it, and when it works, I will create a Class.

    my MainWindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QAxObject>
    6.  
    7. namespace Ui {
    8. class MainWindow;
    9. }
    10.  
    11. class MainWindow : public QMainWindow
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit MainWindow(QWidget *parent = 0);
    17. ~MainWindow();
    18.  
    19. private:
    20. QAxObject *MMDevEnum;
    21. QAxObject *IMMDevEnum;
    22. QAxObject *IAudioMeter;
    23. Ui::MainWindow *ui;
    24. };
    25.  
    26. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 


    my MainWindow.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. #include <QDebug>
    5. #include <QAxObject>
    6. #include <windows.h>
    7. #include <InitGuid.h>
    8.  
    9. //#include "endpointvolume.h"
    10.  
    11. //typedef interface IAudioMeterInformation IAudioMeterInformation;
    12.  
    13. MainWindow::MainWindow(QWidget *parent) :
    14. QMainWindow(parent),
    15. ui(new Ui::MainWindow)
    16. {
    17.  
    18. qDebug() << "going to init";
    19.  
    20. MMDevEnum = new QAxObject(this);
    21. MMDevEnum->setControl("{BCDE0395-E52F-467C-8E3D-C4579291692E}");
    22.  
    23. qDebug() << "instantiated MMDevEnum";
    24.  
    25. IMMDevEnum = new QAxObject(this);
    26. IMMDevEnum->setControl("{A95664D2-9614-4F35-A746-DE8DB63617E6}");
    27.  
    28. IAudioMeter = new QAxObject(this);
    29. IAudioMeter->setControl("{C02216F6-8C67-4B5B-9D00-D008E73E0064}");
    30.  
    31. MMDevEnum->dynamicCall("GetDefaultAudioEndpoint(0, 0, QAxBase::asVariant)", IMMDevEnum->asVariant());
    32.  
    33. qDebug() << "OK";
    34.  
    35. ui->setupUi(this);
    36. }
    37.  
    38. MainWindow::~MainWindow()
    39. {
    40. delete ui;
    41. }
    To copy to clipboard, switch view to plain text mode 


    As you can see, its just a little try.


    However, it fails to instantiate IMMDevEnum and IAudioMeter.

    In the MSDN, "GetDefaultAudioEndpoint" is defined as:
    Qt Code:
    1. HRESULT GetDefaultAudioEndpoint(
    2. [in] EDataFlow dataFlow,
    3. [in] ERole role,
    4. [out] IMMDevice **ppDevice
    5. );
    6.  
    7. /* Example (eRender = 0, eConsole = 0)
    8.  In the preceding code fragment, variable hr is of type HRESULT, pDevEnum is a pointer to an IMMDeviceEnumerator interface, and pDeviceOut is a pointer to an IMMDevice interface.
    9. */
    10. hr = pDevEnum->GetDefaultAudioEndpoint(eRender, eConsole, &pDeviceOut);
    To copy to clipboard, switch view to plain text mode 

    Information about Interface IMMDeviceEnumerator can be found in the MSDN here.

    I don't know why it doesnt work.

    I think that both IMMDevEnum and IAudioMeter doesn´t need to be instantiated, but the Dynamic call still fails: "QAxBase::dynamicCallHelper: Object does not support automation".

    Actually I use mingw, not MSVC.

    Sorry for my bad english!

    Thanks
    Last edited by cocus; 26th June 2012 at 18:25.

Similar Threads

  1. question about threads: calling 'start()->"
    By ErrMania in forum Newbie
    Replies: 3
    Last Post: 23rd November 2011, 18:36
  2. Calling multiple UI's?
    By QtAlexander in forum Newbie
    Replies: 8
    Last Post: 10th December 2010, 22:46
  3. Calling COM object from QT
    By mrityunjay in forum Qt Programming
    Replies: 0
    Last Post: 27th October 2009, 05:25
  4. calling Cmd prompt
    By jsmith in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2009, 09:50
  5. Calling Webservices from QT4
    By Declan in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2007, 08:04

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.