Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. My aplication name

My aplication name

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neliocc
    wrote on last edited by
    #1

    Hi everybody.How can i get the entire path of an aplication when its excecuted??. For example, when the user runs my aplication, i want in the WM_CREATE message, call the function GetAppName created by my and get C:\....\myApp.exe

    S T 2 Replies Last reply
    0
    • N neliocc

      Hi everybody.How can i get the entire path of an aplication when its excecuted??. For example, when the user runs my aplication, i want in the WM_CREATE message, call the function GetAppName created by my and get C:\....\myApp.exe

      S Offline
      S Offline
      Steve Messer
      wrote on last edited by
      #2
      CString GetExePath()
      {
      	CString str;
      	TCHAR szEXEPath[MAX_PATH];
      	
      	GetModuleFileName ( NULL, szEXEPath, MAX_PATH );
      	
      	str = szEXEPath;
      
      	CString s1,s3;
      
      	int pos = str.ReverseFind( '\\' );
      	
      	CString s2;
      
      	s2 = str.Left( pos+1 );
      	return s2;
      }
      

      This should get you started.

      N 1 Reply Last reply
      0
      • S Steve Messer
        CString GetExePath()
        {
        	CString str;
        	TCHAR szEXEPath[MAX_PATH];
        	
        	GetModuleFileName ( NULL, szEXEPath, MAX_PATH );
        	
        	str = szEXEPath;
        
        	CString s1,s3;
        
        	int pos = str.ReverseFind( '\\' );
        	
        	CString s2;
        
        	s2 = str.Left( pos+1 );
        	return s2;
        }
        

        This should get you started.

        N Offline
        N Offline
        neliocc
        wrote on last edited by
        #3

        Thanks a lot

        S 1 Reply Last reply
        0
        • N neliocc

          Thanks a lot

          S Offline
          S Offline
          Steve Messer
          wrote on last edited by
          #4

          No problem good luck coding.

          1 Reply Last reply
          0
          • N neliocc

            Hi everybody.How can i get the entire path of an aplication when its excecuted??. For example, when the user runs my aplication, i want in the WM_CREATE message, call the function GetAppName created by my and get C:\....\myApp.exe

            T Offline
            T Offline
            Tom Archer
            wrote on last edited by
            #5

            While smesser's technique works (using the reversefind), I prefer using the _splithpath so here's an alternative:

            TCHAR buff[MAX_PATH];
            GetModuleFileName(NULL, buff, MAX_PATH);

            char drive[2];
            char dir[MAX_PATH];
            char fname[MAX_PATH];
            char ext[MAX_PATH];
            _splitpath(buff, drive, dir, fname, ext);

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups