Question

Quelqu'un sait comment je peux convertir ce (de C #) à C ++?

string location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ZigbeeCommUSB)).CodeBase);
location = location.Substring(location.IndexOf("\\") + 1);

Merci.

EDIT: Informations supplémentaires

Il est de convertir C # à C ++ natif. S'il y a un autre moyen d'obtenir le chemin du fichier de l'exécutable en cours d'exécution, je suis ouvert aux idées. Merci.

Était-ce utile?

La solution

Exemple de Assembly.GetAssembly à partir du lien ci-dessus

Assembly^ SampleAssembly;
// Instantiate a target object.
Int32 Integer1(0);
Type^ Type1;
// Set the Type instance to the target class type.
Type1 = Integer1.GetType();
// Instantiate an Assembly class to the assembly housing the Integer type.  
SampleAssembly = Assembly::GetAssembly( Integer1.GetType() );
// Gets the location of the assembly using file: protocol.
Console::WriteLine( "CodeBase= {0}", SampleAssembly->CodeBase );

Si vous Combind ce qui précède, vous aurez probablement venir un peu plus près ce que vous voulez faire. Si cela va être fait dans C ++ natif, vous aurez un peu plus problème, il y a quelque chose appelé "API Fusion" qui pourrait vous aider à chercher des assemblages dans le GAC

Autres conseils

Pour récupérer le chemin de l'exécutable en cours, utilisez

scroll top