![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Location: Portland, OR
Posts: 12
Rep Power: 0
![]() |
GetModuleFileName() with console app?
Hi everyone:
It seems to be very easy but somehow I'm stuck in the middle of it. The GetModuleFileName(hModule, pFileName, nSz) returns NULL if hModule refers to console app (and probably 16bit app too). There's absolutely no way around it as I need to get file path from the window handle. Any suggestions? |
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 599
Rep Power: 4
![]() |
works ok for me (VC++ 6.0 compiler and XP). win32 api functions can't be called from 16-bit programs.
#include <windows.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
char buf[_MAX_PATH];
if( GetModuleFileName(NULL,buf,sizeof(buf)) )
cout << buf << endl;
else
cout << "GetModuleFileName() failed" << endl;
cin.ignore();
return 0;
} |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Why not look at argv[0]? If it is non-null, it is usually the name of your program.
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jun 2005
Location: Portland, OR
Posts: 12
Rep Power: 0
![]() |
Sorry guys I didn't put it clear. I need to run GetModuleFileName() for HMODULE in another process. Basically what happens, I have HWND that I receive from WindowFromPoint(), then I get HMODULE off of it, and the goal is to get module path. I run it from GUI app on Windows XP. It works fine with exception of console windows and 16bit apps.
|
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Quote:
Under windows windows NT/2000/XP .... 16 bit apps run within the DOS emulator (an executable named NTVDM.EXE), and that does not provide a means of identifying the applications being run in the DOS virtual machine. At best, you will be able to get NTVDM.EXE as the module name. My memory suggests console applications run within an environment set up by the command line processor (CMD.EXE), and that also does not provide a means of identifying individual applications running within it. I'm less certain on that, so you may wish to check further ....... Under windows 95/98/Me ..... the story may be different. |
|
|
|
|
|
|
#6 |
|
Newbie
Join Date: Jun 2005
Location: Portland, OR
Posts: 12
Rep Power: 0
![]() |
Thanks! Doesn't sound simple though
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|