Results 1 to 10 of 10
  1. #1
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed

    Getting Current Path of Executable + Adding On a File

    I want to get the current path of my executable, and add "Untitled.txt" for I can always instantly know the path to Untitled.txt if its in the same directory as my exe. I also would like the final result as a "char". Any help is appreciated, and trust me I already tried google as well as other basic C++ functions and i could not get it.


    Edit : I used the "System::Windows::Forms" namespace to find the path now how would I had Untitled.txt to it.
    Last edited by CoderNever; 08-06-2010 at 07:59 AM.

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Damn you made me type this up for nothing. >_>

  3. #3
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed
    Quote Originally Posted by CoderNever View Post
    I want to get the current path of my executable, and add "Untitled.txt" for I can always instantly know the path to Untitled.txt if its in the same directory as my exe. I also would like the final result as a "char". Any help is appreciated, and trust me I already tried google as well as other basic C++ functions and i could not get it.


    Edit : I used the "System::Windows::Forms" namespace to find the path now how would I had Untitled.txt to it.
    I Still need to findout how to add Untitled.txt to it xD .

  4. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    [php]
    char* GetExecutablePath(char* ExecutableName)
    {
    //Find process
    PROCESSENTRY32 Pe;
    Pe.dwSize = sizeof( PROCESSENTRY32 );

    HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);

    Process32First(snapshot,&Pe);
    do {
    if( !strcmp(Pe.szExeFile,ExecutableName) )
    break;
    } while(Process32Next(snapshot,&Pe));

    //Find executable module and return path
    MODULEENTRY32 Me;
    Me.dwSize = sizeof( MODULEENTRY32 );
    HANDLEh snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,Pe.dw32 thProcessID);

    Module32First(hsnapshot,&Me);
    do {
    if( !strcmp(Me.szModule,Executable) )
    return Me.szExePath;
    } while(Module32Next(hsnapshot,&Me);
    return NULL;
    }

    int main()
    {
    char* path = GetExecutablePath("winmine.exe");
    char* Filename = "\\Untitled.txt";
    path += Filename;

    ofstream File(path); //creates if doesn't exist
    }
    [/php]

    Idk if that's going to work, I'm not on Windows, can't test anything..

  5. #5
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed
    I'm getting these 2 errors..

    Code:
    error C2374: 'snapshot' : redefinition; multiple initialization
     see declaration of 'snapshot'
    error C2039: 'dw32ProcessID' : is not a member of tagPROCESSENTRY32'
    and here is the line there both on...

    Code:
     HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,Pe.dw32ProcessID);

  6. #6

  7. #7
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed
    Handleh, and hSnapshot are not found. then we also get this..
    Code:
    'dw32thProcessID' : is not a member of 'tagPROCESSENTRY32'

    Do you think something like this could work...
    Code:
    this->textBox1->Text = Windows::Forms::Application::StartupPath->Insert(Windows::Forms::Application::StartupPath->Length,"\untitled.txt");
    Last edited by CoderNever; 08-06-2010 at 08:22 AM.

  8. #8
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    doesnt + work in managed C++?

    Code:
    string a = "LOLWUT";
    MessageBox.Show(a+" I AM LEET");
    works in c#
    Ah we-a blaze the fyah, make it bun dem!

  9. #9
    CoderNever's Avatar
    Join Date
    Feb 2009
    Gender
    female
    Location
    https://mpgh.net MPGHCash: $700,458,011
    Posts
    1,198
    Reputation
    131
    Thanks
    2,236
    My Mood
    Buzzed
    Nope that ain't working. I fixed it though .

  10. #10
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Why in the world are you using managed C++? ):

  11. The Following User Says Thank You to Void For This Useful Post:

    Hell_Demon (08-07-2010)

Similar Threads

  1. I get added from the most...
    By Skyline. in forum General
    Replies: 36
    Last Post: 06-12-2011, 07:25 AM
  2. Ads get upgrade
    By -InFinity in forum General
    Replies: 12
    Last Post: 11-21-2010, 09:20 AM
  3. how do u get rid of ads on a hack?
    By machuhoya in forum Combat Arms Help
    Replies: 5
    Last Post: 01-19-2010, 01:13 AM
  4. Getting the path of a running process?
    By *Marneus901* in forum C++/C Programming
    Replies: 0
    Last Post: 12-08-2008, 01:51 PM
  5. Get Process name, PID, User, Path
    By Token in forum C++/C Programming
    Replies: 3
    Last Post: 10-17-2008, 09:45 AM