I've searched the board several times, but haven't found anything about getting the name of the program itself.
I've searched the board several times, but haven't found anything about getting the name of the program itself.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Can you be more specific.. getting the name of the program your running? Name of what...?
ok. My program is obvious.exe and when you run it, I want to MessageBox obvious.exe. If, however, you rename it to ah.exe, the program should MessageBox ah.exe
Last edited by neandrake; 12-06-2003 at 02:11 PM.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
have you tried to look in argv[0]?
Code:int main(int argc, char* argv[]) { printf("%s", argv[0]); return 0; }
ggCode:#include <stdio.h> int main (int argc, char *argv[]) { printf("%s", argv[0]); return 0; }
well i figured you'd guys be smart enough to figure out that I put this in the Windows section for a reason...
Is there no api function to retrieve this?
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
I usually view new threads, and don't look in which forum they are.Originally posted by neandrake
well i figured you'd guys be smart enough to figure out that I put this in the Windows section for a reason...
Is there no api function to retrieve this?
Hmm, have you looked in lpCmdLine? Maybe Windows has something similar to argv[0].
Last edited by glUser3f; 12-06-2003 at 02:28 PM.
Yes, I have tested lpCmdLine and it doesn't include the name, only arguments/parameters passed to the program.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Could you please explain more? what do you mean by "I want to MessageBox obvious.exe?" Do you want to show a message box containing the exe name?Originally posted by neandrake
ok. My program is obvious.exe and when you run it, I want to MessageBox obvious.exe. If, however, you rename it to ah.exe, the program should MessageBox ah.exe
I was just giving an example. I know how to MessageBox. I'm trying to make a sort of 'install' for my program and I need to know the location (gotten with GetCurrentDirectory()) and I need to get the name of the program (in case someone renames it). If my program was "C:\Program Files\MyProgram\Barfsnort.exe" but the user decided to rename it to Snortbarf.exe, then I have to update settings.
All I need to know is how to get the name of the program
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
call the function GetCommandLine().
Code:#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { MessageBox(NULL, GetCommandLine(), "Program exe: ", MB_OK); return 0; }
Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.
OS: Windows XP
Compiler: MSVC
slick hybrid, very slick
god I knew it was a one-liner
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
That call will include command line arguments though, if they exist.
Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.
OS: Windows XP
Compiler: MSVC
damnit
lool
hrm
So I use a string function to remove lpCmdLine from GetCommandLine(), and it should be fine, right?
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Well in a call to GetCommandLine() the exe path is in quotes of its own, so it shouldn't be too hard to separate.
Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.
OS: Windows XP
Compiler: MSVC