[gme-users] Help with paradigm registration

Aditya Agrawal Aditya at isis.vanderbilt.edu
Thu Jul 22 17:39:06 CDT 2004


Dear Kitty,

I am not an expert in using COM through C++ but think you will need to
include the MgaUtil.idl and MgaUtils.h file from C:\Program
Files\GME\Interfaces and then in your main program you will use 

COMTHROW(fcocoll.CoCreateInstance(CComBSTR("Mga. Mga.MgaRegistrar"))); 

I hope this helps.

Adi

------------------------------------------
Aditya Agrawal 
mailto:aditya.agrawal at vanderbilt.edu
http://aditya.isis.vanderbilt.edu/
Institute For Software Integrated Systems (ISIS) www.isis.vanderbilt.edu

Vanderbilt University 
2015 Terrace Place 
Nashville, TN 37203
615 322 3164


> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu [mailto:gme-users-
> bounces at list.isis.vanderbilt.edu] On Behalf Of Krishnakumar B
> Sent: Thursday, July 22, 2004 11:40 AM
> To: gme-users
> Subject: [gme-users] Help with paradigm registration
> 
> Hi,
> 
> I am trying to make an installer for our toolsuite. As part of
finishing
> up
> the installation, I would like to register the paradigm with GME. I
saw
> some example code in InstallScript which looked something like:
> 
> try
>    set oGME = CreateObject("Mga.MgaRegistrar");
> catch
>    SendErrorMsg(hInstall, "Can't create Mga.MgaRegistrar
>                 object. Please check if you have a valid GME
installaton.
>                 \n" + Err.Description, 1);
> endcatch;
> // System-wide register
> nParadigmRegMode = REGACCESS_SYSTEM;
> nBuffer = 256;
> 
> // Register the UML paradigm
> 
> svParadigmDir = INSTALLDIR ^ "etc";
> nParadigmRegMode = REGACCESS_USER;
> svParadigmName = "UML.xmp";
> 
> // User registeration
> SendMsgToProgressBar(hInstall, svParadigmName);
> try
>                 oGME.RegisterParadigmFromData("XML=" + svParadigmDir ^
> svParadigmName, svParadigmRegName, nParadigmRegMode);
> catch
>                 SendErrorMsg(hInstall, "Can't register Paradigm
>                 "+svParadigmDir ^ svParadigmName +". Please check if
you
> have a valid GME installaton. \n" + Err.Description, 1);
> endcatch;
> 
> I am trying to write a C++ equivalent of the above (with the hope of
> making
> an executable someday which can be installed as a custom action in the
MSI
> that I am creating). I need some information/help about the internal
> functions of GME. If you see the above snippet, it creates a COM
object
> and
> calls RegisterParadigmFromData(). So can someone please help me with
the
> small bit of magic needed to do the same with C++?
> 
> I tried the following but it wouldn't compile (obvious since I don't
know
> COM). Also where can I get information about the API supported by
> Mga.MgaRegistrar inteface?
> 
> Any help is very much appreciated.
> 
> Thanks,
> kitty.
> 
> 
> 
> UINT __stdcall RegisterParadigm (MSIHANDLE hInstall)
> {
>   // installable paradigm number
>   int nParadigmNum = 0;
> 
>   // Initialize progress bar
>   InitProgressBar(hInstall, nParadigmNum, PARADIGMCOST,
>                   "Paradigm Install",
>                   "Registering Paradigms into GME.", "Registering
[1]");
> 
>   // Try to get the GME COM object
>   CObject* GME = CreateObject("Mga.MgaRegistrar");
>   if (GME == NULL)
>     SendErrorMsg (hInstall, "Can't create Mga.MgaRegistrar object.
Please
> check"
>                   "if you have a valid GME installaton. \n" +
LastError(),
> 1);
>   const int nBuffer = 256;
> 
>   char* value = GetRegistryValue (HKEY_LOCAL_MACHINE,
>                                   "SOFTWARE\\ISIS\\CoSMIC",
>                                   "TargetDir");
>   if (value == 0)
>     SendErrorMsg (hInstall, "Unable to access Registry Key TargetDir",
1);
> 
>   CString targetDir (value);
> 
>   // Register the PICML paradigm
> 
>   CString svParadigmDir = targetDir + "paradigms";
> 
>   // User-wide register
>   int nParadigmRegMode = REGACCESS_USER;
>   CString svParadigmName = "PICML.xmp";
> 
>   // User registeration
>   SendMsgToProgressBar(hInstall, svParadigmName);
>   try
>     {
>       GME->RegisterParadigmFromData("XML=" + svParadigmDir +
> svParadigmName,
>                                     svParadigmRegName,
nParadigmRegMode);
>     }
>   catch (...)
>     {
>       SendErrorMsg (hInstall, "Unable to register Paradigm " +
> svParadigmDir +
>                    svParadigmName + ". Please check if you have a
valid
> GME"
>                    "installation. \n" + LastError(), 1);
>     }
> 
>   // System Wide registration
>   nParadigmRegMode = REGACCESS_SYSTEM;
>   SendMsgToProgressBar(hInstall, svParadigmName);
>   try
>     {
>       GME->RegisterParadigmFromData("XML=" + svParadigmDir +
> svParadigmName,
>                                     svParadigmRegName,
nParadigmRegMode);
>     }
>   catch (...)
>     {
>       SendErrorMsg (hInstall, "Unable to register Paradigm " +
> svParadigmDir +
>                    svParadigmName + ". Please check if you have a
valid
> GME"
>                    "installation. \n" + LastError(), 1);
>     }
>   return ERROR_SUCCESS;
> }
> 
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users


More information about the gme-users mailing list