Conversion c++ vers c#

survcopt Messages postés 224 Date d'inscription mardi 27 mai 2003 Statut Membre Dernière intervention 13 mai 2022 - 15 mars 2009 à 20:21
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 - 23 mars 2009 à 20:06
Bonjour,
Je cherche à convertir le code d'une dll dont j'ai le source qui est écrit en c++ vers une version en c# car je maîtrise mieux ce langage.
Je cherche donc une âme charitable capable de m'expliquer certaines subtilité de ce code .
je vais que certaines bout de code qui résume le code principale car tout fonctionne pareil après.
Le code est écrit avec visual studio 2005
dans le .cpp

Déclaration de constante liées à la dll
// plugin information
unsigned g_uPluginID          = 0;
char     g_szPluginName[]     = "ExampleInternalsPlugin - 2005.11.30";
unsigned g_uPluginVersion     = 001;
unsigned g_uPluginObjectCount = 1;
InternalsPluginInfo g_PluginInfo;

Déclaration des routines de ce .cpp
// interface to plugin information
extern "C" __declspec(dllexport)
const char* __cdecl GetPluginName() { return g_szPluginName; }
extern "C" __declspec(dllexport)
unsigned __cdecl GetPluginVersion() { return g_uPluginVersion; }
extern "C" __declspec(dllexport)
unsigned __cdecl GetPluginObjectCount() { return g_uPluginObjectCount; }

????
// get the plugin-info object used to create the plugin.
extern "C" __declspec(dllexport)
PluginObjectInfo* __cdecl GetPluginObjectInfo( const unsigned uIndex )
{
  switch(uIndex)
  {
    case 0:
      return  &g_PluginInfo;
    default:
      return 0;
  }
}

????????????
InternalsPluginInfo::InternalsPluginInfo()
{
  // put together a name for this plugin
  sprintf( m_szFullName, "%s - %s", g_szPluginName, InternalsPluginInfo::GetName() );
}

const char*    InternalsPluginInfo::GetName()     const { return ExampleInternalsPlugin::GetName(); }
const char*    InternalsPluginInfo::GetFullName() const { return m_szFullName; }
const char*    InternalsPluginInfo::GetDesc()     const { return "Example Internals Plugin"; }
const unsigned InternalsPluginInfo::GetType()     const { return ExampleInternalsPlugin::GetType(); }
const char*    InternalsPluginInfo::GetSubType()  const { return ExampleInternalsPlugin::GetSubType(); }
const unsigned InternalsPluginInfo::GetVersion()  const { return ExampleInternalsPlugin::GetVersion(); }
void*          InternalsPluginInfo::Create()      const { return new ExampleInternalsPlugin(); }

???
PluginObjectInfo *ExampleInternalsPlugin::GetInfo()
{
  return &g_PluginInfo;
}

Fonction qui est appellée avec comme paramètre un nom de fichier est une string à rajouter dans celui-ci
void ExampleInternalsPlugin::WriteToAllExampleOutputFiles( const char * const openStr, const char * const msg )
{
    ...
}

Fonction qui est appellée quand le programme commmence

void ExampleInternalsPlugin::Startup()
{
    ...   
}

En fait je ne comprends pas sont déclarées les fonctions dans le programme .
le nom de ma solution : InternalsPlugin
le nom du projet : InternalsPlugin

merci pour votre aide..

www.survey-copter.com

3 réponses

survcopt Messages postés 224 Date d'inscription mardi 27 mai 2003 Statut Membre Dernière intervention 13 mai 2022 1
16 mars 2009 à 09:15
Merci pour ton aide :-)
En fait je cherche à comprendre ce que veux dire
ExampleInternalsPlugin::Startup()

www.survey-copter.com
0
cs_rt15 Messages postés 3874 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 7 novembre 2014 13
23 mars 2009 à 20:06
Salut,

InternalsPluginInfo::InternalsPluginInfo()

Implémentation du constructeur de la classe InternalsPluginInfo.

PluginObjectInfo *ExampleInternalsPlugin::GetInfo()

Méthode GetInfo de la classe ExampleInternalsPlugin, renvoyant un pointeur sur une instance de PluginObjectInfo.

extern "C" __declspec(dllexport)

__declspec(dllexport) -> La fonction va être exporté. Cela veut dire que son nom sera mis dans la table d'export du fichier exécutable résultant (.dll, .ocx...). Donc un autre exécutable pourra appeler cette fonction après avoir charger l'autre fichier exécutable.

extern "C" -> Pour ne pas être gené par le C++ qui a tendance à mettre un peu n'importe quoi comme nom de fonction. On dit que c'est une fonction comme C.

Hésite pas à redemander si j'ai pas été assez clair.
0
gnairod Messages postés 37 Date d'inscription samedi 22 novembre 2008 Statut Membre Dernière intervention 11 avril 2010
15 mars 2009 à 23:57
Ouai et ?
-1
Rejoignez-nous