Einzelnen Beitrag anzeigen

Benutzerbild von sniper_w
sniper_w

Registriert seit: 11. Dez 2004
Ort: Wien, Österriech
893 Beiträge
 
Delphi 6 Enterprise
 
#26

Re: ExtractFilePath für C++

  Alt 30. Nov 2007, 22:31
Code:
#include <windows.h>
#include <iostream>
#include <string>

using std::string;

int main()
{
    char moduleName[1024];

    if(!GetModuleFileName( NULL, moduleName, 1024))
    {
        std::cout << "GetModuleHandle failed!!" << std::endl;
        return 0;
    }
    else
    {
        std::cout << moduleName << std::endl;
    }

    string filePath;

    filePath.assign(moduleName);

    int pos = filePath.find_last_of('\\');
    filePath.erase(pos+1);

    std::cout << filePath << std::endl;

   return 0;
}
Katura Haris
Es (ein gutes Wort) ist wie ein guter Baum, dessen Wurzel fest ist und dessen Zweige in den Himmel reichen.
  Mit Zitat antworten Zitat