survcopt
Messages postés224Date d'inscriptionmardi 27 mai 2003StatutMembreDernière intervention13 mai 2022
-
15 mars 2009 à 20:21
cs_rt15
Messages postés3874Date d'inscriptionmardi 8 mars 2005StatutModérateurDerniè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() );
}
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
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.