[gmpi] Re: calling C from C++

  • From: Jeff McClintock <jeffmcc@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Mon, 14 Feb 2005 18:26:09 +1300

Cheers All,

--------------gmpi.c--------------------------------------
#include <stdio.h>
#include "gmpi.h"

//int _tmain(int argc, _TCHAR* argv[])
int main(int argc, char* argv[])
{
        /* signature of Factory construction function */
        GMPI_DllEntry dll_entry_point;
        GMPI_DllHandle dll_handle;
        IGMPI_Factory *factory;
        IGMPI_Plugin *my_plugin;
        GMPI_RESULT r;

/* format of plugin unique ID undecided. for now using GUID */
/* {5CC85CAD-DC0C-42c2-80FD-DC3ADBC70641} */
static const GUID IID_GMPI_Prototype_DSP =
{ 0x5cc85cad, 0xdc0c, 0x42c2, { 0x80, 0xfd, 0xdc, 0x3a, 0xdb, 0xc7, 0x6, 0x41 } };



/* STEP 1: Load DLL */ r = GMPI_DllLoad( &dll_handle, "../test_plugin/debug/test_plugin.dll" );

    /* STEP 2: Locate entrypoint */
        r = GMPI_DllSymbol( &dll_handle, "DllGetClassObject", &dll_entry_point 
);


/* STEP 3: Create factory */
r = (dll_entry_point)( &IID_GMPI_Factory, &IID_GMPI_Factory, (void**) &factory );



/* STEP 4: Ask factory to instantiate plugin */
r = (factory->Vtable->CreateInstance)(factory, &IID_GMPI_Prototype_DSP, (void**) &my_plugin);



// test a call into plugin r = (my_plugin->Vtable->Placeholder1)(my_plugin, 42);


/* STEP 5: delete factory and plugin */ r = (my_plugin->Vtable->Release)(my_plugin); r = (factory->Vtable->Release)(factory); return 0; }


---------------------------------------------------------------------- Generalized Music Plugin Interface (GMPI) public discussion list Participation in this list is contingent upon your abiding by the following rules: Please stay on topic. You are responsible for your own words. Please respect your fellow subscribers. Please do not redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: