2009/01/12(Mon).NET から mixer だぁ?

はてブ数 2009/01/12 8:00 計算機な日記::ソフト作り つーさ

題名の通り。あんまり突っ込んでやるつもりはなかったものの

#pragma once

using namespace System;
namespace SndVol32 {

    public ref class Mixer
    {
        HMIXER hmx;

    public:
        static int GetNumDevs()    { return (int)mixerGetNumDevs(); }
        static array<String^> ^ GetDevices()
        {
            array<String^>^ devices = gcnew array<String^>(GetNumDevs());
            for(int i=0; i<devices->Length; i++)
            {
                MIXERCAPS c = { 0 };
                mixerGetDevCaps( (UINT_PTR)i,&c, sizeof(MIXERCAPS));
                devices[i] = gcnew String(c.szPname);
            }
            return devices;
        }

        Mixer(int uDevID)
        {
            MMRESULT r;
            r = mixerOpen(&hmx, (UINT) uDevID, 0, 0, 0);
            if(r != MMSYSERR_NOERROR)
                throw gcnew Exception("Error" + r.ToString());
        }
    };
}

まで書いてビルドしたら、

エラー	1	error C2664: 'mixerOpen' : 1 番目の引数を 'cli::interior_ptr<Type>' から 'LPHMIXER' に変換できません。(新しい機能 ; ヘルプを参照)	e:\\my documents\\visual studio 2008\\projects\\sndvol32\\sndvol32.h	29	sndvol32

挫折しました。
構造体やAPIのポーティングがめんどいと思って、C++/CLIとか使うと、
理解を超えるエラーメッセージが出て、余計めんどい罠。

でも、.NETがなければ私はもうプログラムが書けない。
なんという.NET依存症。
すっかりMicrosoftの思うつぼなのかもしれない。