Thread: Isolating

  1. #1
    Registered User
    Join Date
    Mar 2007


    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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    Have you searched the forum? It was just discussed recently (if not yesterday)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    Registered User
    Join Date
    Oct 2006
    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, 02:16 PM