GitXplorerGitXplorer
a

aimp_api_wrappers

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
75d17604049e1b21f38c4f1af402c6b635b4614a

Add license file

aalexesprit committed 5 years ago
Unverified
2df080ea11e1baab25fdb8a335a42f6753735fb0

Update readme

aalexesprit committed 9 years ago
Unverified
9564b2dd28ccd644eb8182ef3802a2eb12f45b03

guid: print message if all GUIDs are equal'

aalexesprit committed 9 years ago
Unverified
bf485f8f724ce43e28f61b246fdae3325e6fb1b2

Update comtypes.h

aalexesprit committed 9 years ago
Unverified
3cbf8d0c3eeaed0ae190f2d488166ec4f34a6e43

Add `IsServiceAvailable(REFIID)` method

aalexesprit committed 10 years ago
Unverified
015c8184764801db8b5dbd4dd0332cd6f1da1258

Use com_ptr_t objects instead of object pointers

aalexesprit committed 10 years ago

README

The README file for this repository.

AIMP C++ API Wrappers

Wrappers for AIMP API written in C++ (like apiWrappers and AIMPCustomPlugin for Delphi).

Table of contents

  1. Usage
  2. Smart pointers

Usage

Here is an example of core wrapper usage:

/**
 * File: MyAIMPPlugin.h
 */

#pragma once
#include "AIMPCustomPlugin.h"

// Descendant of AIMPCustomPlugin
class MyAIMPPlugin : public AIMPCustomPlugin {
public:
    virtual HRESULT WINAPI Initialize(IAIMPCore* Core);
    virtual HRESULT WINAPI Finalize();

    virtual PWCHAR WINAPI InfoGet(int Index);
    virtual DWORD WINAPI InfoGetCategories();

    virtual void WINAPI SystemNotification(int NotifyID, IUnknown* Data);
};
/**
 * File: MyAIMPPlugin.cpp
 */

#include "MyAIMPPlugin.h"

HRESULT WINAPI MyAIMPPlugin::Initialize(IAIMPCore* Core) {
    // Base method call is required.
    if (SUCCEEDED(AIMPCustomPlugin::Initialize(Core))) {
        // Okey, let's use one of help methods.
        IAIMPString* testString = aimpCore->MakeString(L"It works!");
        MessageBox(
            aimpCore->MainWindowGetHandle(),
            testString->GetData(), L"AIMP", MB_OK);
        testString->Release();
        // Put your data initialization here.
        return S_OK;
    }
    return E_ABORT;
}

HRESULT WINAPI MyAIMPPlugin::Finalize() {
    // Put your data finalization here.
    // Base method call is required.
    return AIMPCustomPlugin::Finalize();
}

// ...

Smart pointers

Use smart COM object pointers:

  1. Include comtypes.h in your stdafx.h or in any file.
  2. Start using new types like in this example:
void MyPlugin::TestMethod() {
    IAIMPMenuItemPtr menuItem;
    if (aimpCore->CreateObject(IID_IAIMPMenuItem, (void**)&menuItem)) {
        IAIMPServiceMenuManagerPtr menuManager;
        if (aimpCore->GetService(IID_IAIMPServiceMenuManager, (void**)&menuManager)) {
            IAIMPMenuItemPtr parentMenuItem;
            if (SUCCEEDED(menuManager->GetBuiltIn(AIMP_MENUID_PLAYER_MAIN_OPEN, &parentMenuItem))) {
                IAIMPStringPtr menuName, menuId;
                aimpCore->MakeString(MENU_UPDATE_COLOR_SCHEME_ID, &menuId);
                aimpCore->LangLoadString(LNG_UPDATE_COLOR_SCHEME, &menuName);

                menuItem->SetValueAsObject(AIMP_MENUITEM_PROPID_ID, menuId);
                menuItem->SetValueAsObject(AIMP_MENUITEM_PROPID_NAME, menuName);
                menuItem->SetValueAsObject(AIMP_MENUITEM_PROPID_PARENT, parentMenuItem);
                menuItem->SetValueAsInt32(AIMP_MENUITEM_PROPID_STYLE, AIMP_MENUITEM_STYLE_NORMAL);

                aimpCore->RegisterExtension(IID_IAIMPServiceMenuManager, menuItem);
            }
        }
    }
} // All variables have leaved its scope, and COM objects instances will be removed automatically.