read the exe name

This is a discussion on read the exe name within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I want to print in the console the name of the exe that is executed (It prints his name). ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    read the exe name

    Hi, I want to print in the console the name of the exe that is executed (It prints his name). There is something I can do for read it?

    thanx
    This forum is the best one I've ever seen. Great ppl, great coders

  2. #2
    I like code Rouss's Avatar
    Join Date
    Apr 2004
    Posts
    131
    You can use command line arguments.
    Code:
    int main(int argc, char **argv)
    {
        printf("Program Executed = %s\n", argv[0]);
        return 0;
    }

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    too bad I cant use int main, but I have to use WINAPI WinMain and the command line argument is only one lpCmdLine and no exe name in it...
    This forum is the best one I've ever seen. Great ppl, great coders

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    Must be a windows question then
    This question has been answered before on the windows board, try a search
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    thanx, I will search it (again and better)
    This forum is the best one I've ever seen. Great ppl, great coders

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Code:
    #include <windows.h>
    #include <iostream>
    
    
    int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
    {
    	MessageBox(HWND_DESKTOP,GetCommandLine(),0,MB_OK);
    	return 0;
    }

  7. #7
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    really thanx
    This forum is the best one I've ever seen. Great ppl, great coders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird read input or bad printf output?
    By ChaoticMachiner in forum C Programming
    Replies: 3
    Last Post: 05-04-2008, 04:40 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. I am lost on how to read from file and output to file?
    By vicvic2477 in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2005, 11:52 AM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 03:09 AM

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