Getting prog. FileName...

This is a discussion on Getting prog. FileName... within the Windows Programming forums, part of the Platform Specific Boards category; I am working on improving my window manager, and I want to tell the window's name and its file name. ...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Getting prog. FileName...

    I am working on improving my window manager, and I want to tell the window's name and its file name. I already have it all except the file name. I tried ways of GetModuleFileName();, but they aren't working. How do I get the file name of an open window?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  2. #2
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    235
    There would be several problems in this, syntax. Would you get the last current document? All of them of one window? What view class are you getting them from (RichEdit, HTML, Tree, List)? But If I were you I would mess around with sorting parent and child windows first, then refine your function.
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  3. #3
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Use GetWindowModuleFileName().
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question GetWindowModuleFileName() not working

    I tried it, but it says implicit declaration of int GetWindowModuleFileName(...);
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  5. #5
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    You may need an update of the Platform SDK. I'm guessing it's a relatively new function.

  6. #6
    Registered User ExDigit's Avatar
    Join Date
    Jan 2002
    Posts
    31

    It can't be that new

    I found that function in the Win32 API Reference - perhaps you haven't linked the libraries properly or have forgotten to include <windows.h> (I doubt it)? Anyway:
    he GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module.

    Windows 95: The GetModuleFilename function will return long filenames when an application’s version number is greater than or equal to 4.00 and the long filename is available. Otherwise, it returns only 8.3 format filenames.

    DWORD GetModuleFileName(

    HMODULE hModule, // handle to module to find filename for
    LPTSTR lpFilename, // pointer to buffer for module path
    DWORD nSize // size of buffer, in characters
    );
    Parameters

    hModule

    Identifies the module whose executable filename is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process.

    lpFilename

    Points to a buffer that is filled in with the path and filename of the given module.

    nSize

    Specifies the length, in characters, of the lpFilename buffer. If the length of the path and filename exceeds this limit, the string is truncated.

    Return Values

    If the function succeeds, the return value is the length, in characters, of the string copied to the buffer.
    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    Remarks

    If a module is loaded in two processes, its module filename in one process may differ in case from its module filename in the other process.

    See Also

    GetModuleHandle, LoadLibrary
    Not sure.

  7. #7
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    You need to update your Windows header files. That function is defined in winuser.h, so you'll need to paste its definition into the file already on your system. Here's the listing from the SDK:

    Code:
    WINUSERAPI UINT WINAPI GetWindowModuleFileNameA(
       IN HWND hwnd,
       OUT LPSTR pszFileName,
       IN UINT cchFileNameMax);
    WINUSERAPI UINT WINAPI GetWindowModuleFileNameW(
       IN HWND hwnd,
       OUT LPWSTR pszFileName,
       IN UINT cchFileNameMax);
    #ifdef UNICODE
    #define GetWindowModuleFileName GetWindowModuleFileNameW
    #else
    #define GetWindowModuleFileName GetWindowModuleFileNameA
    #endif
    You might want to download a fresh edition of the SDK (November is the most current), especially if you're using Dev-C++.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-11-2009, 02:49 AM
  2. Pass Filename to another function
    By awesmesk8er in forum C Programming
    Replies: 9
    Last Post: 10-24-2008, 02:43 PM
  3. adding line numbers and concatenating a filename
    By durrty in forum C Programming
    Replies: 25
    Last Post: 06-28-2008, 04:36 AM
  4. Time as filename
    By rkooij in forum C Programming
    Replies: 8
    Last Post: 03-02-2006, 09:17 AM
  5. Replies: 3
    Last Post: 01-25-2006, 10:30 PM

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