Isolating

This is a discussion on Isolating within the C++ Programming forums, part of the General Programming Boards category; I think this is the right place to post and not in the windows programming forum, since my question is ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    38

    Isolating

    I think this is the right place to post and not in the windows programming forum, since my question is more about the syntax..

    Well I'm using GetModuleFileName to get the complete path to the file. As a result I get this: C:\project\program.exe

    Is there a way to isolate the "program.exe"? All I'm trying to do is get the process name so I can get his PID, I know how to do it if I know the name, but if someone renames it I can't. Thats why I'm trying to isolate the program.exe so I can always know the name.

    Thanks <3

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Have you searched the forum? It was just discussed recently (if not yesterday)
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    using <string>, maybe try a function like 'rfind' or 'find_last_of' functions to find the position of the last occurrence of '\' or '/' (since windows lets you use either). anything after that position is the program name. if neither slash is found the file may be in the current directory (simply "program.exe") in which case use the entire string.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. convert int to char without a bus error
    By petz_e in forum C Programming
    Replies: 6
    Last Post: 11-14-2008, 04:43 PM
  2. trouble isolating special utf-8 character in string
    By myrddinemrys in forum C Programming
    Replies: 3
    Last Post: 12-30-2007, 03:21 AM
  3. Isolating a C++ function/module with C
    By freedomnet in forum C Programming
    Replies: 2
    Last Post: 05-11-2004, 03:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21