Domanda

Qualcuno sa come posso convertire questo (da C #) per C ++?

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

Grazie.

EDIT: Ulteriori informazioni

Si tratta di convertire da C # per C ++ nativo. Se non v'è altro modo per ottenere il percorso del file dell'eseguibile attualmente in esecuzione, io sono aperto a idee. Grazie.

È stato utile?

Soluzione

Esempio di Assembly.GetAssembly dal link qui sopra

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 );

Se si Combind quanto sopra, è probabilmente venuto un po 'più vicino a quello che si vuole fare. Se questo sta per essere fatto in C ++ nativo, si avrà un po 'più problema, c'è qualcosa che si chiama "Fusion API" che aiuto potrebbe cercate assembly nella Global assembly Cache

Altri suggerimenti

per recuperare il percorso del file eseguibile corrente, utilizzare GetModuleFileName utilizzando un argomento NULL hModule.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top