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. File Handle(very urgent)

File Handle(very urgent)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
5 Posts 2 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.
  • S Offline
    S Offline
    swaapu
    wrote on last edited by
    #1

    HI! I have used the GetModuleFileName function in my MFC SDI application. The syntax is: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // path buffer DWORD nSize // size of buffer ); Parameters hModule [in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module. Now, the problem is with the HModule parameter. But, I don`t know how to set the handle to the module or file. What type of variable to declare. NULL is not serving my purpose. Thanx

    K 1 Reply Last reply
    0
    • S swaapu

      HI! I have used the GetModuleFileName function in my MFC SDI application. The syntax is: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // path buffer DWORD nSize // size of buffer ); Parameters hModule [in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module. Now, the problem is with the HModule parameter. But, I don`t know how to set the handle to the module or file. What type of variable to declare. NULL is not serving my purpose. Thanx

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      Your question is not very clear. Anyway, If you want to get the filepath of the current exe file, then you can set it to NULL: char str[MAX_PATH]; GetModuleFileName(NULL,str,MAX_PATH); Will get the current exe's path. If you want the path for another file, like a DLL, then when you load it using HMODULE hModule; hModule = LoadLibrary(...), its handle is returned. This is the same handle for use with GetModuleFileName(...). this is this.

      S 1 Reply Last reply
      0
      • K khan

        Your question is not very clear. Anyway, If you want to get the filepath of the current exe file, then you can set it to NULL: char str[MAX_PATH]; GetModuleFileName(NULL,str,MAX_PATH); Will get the current exe's path. If you want the path for another file, like a DLL, then when you load it using HMODULE hModule; hModule = LoadLibrary(...), its handle is returned. This is the same handle for use with GetModuleFileName(...). this is this.

        S Offline
        S Offline
        swaapu
        wrote on last edited by
        #3

        Hi! I hav an MFC SDI Application with two dialogs. One is for selecting source file and the other is for selecting destination file. BOth, dialogs have one edit box for browsing or editing the path of file. Actually, I don`t want to get the path of current exe. Instead, I want to get the file path from edit box of another file. I want to get the path , which was entered in the edit box for file name on the SelectSource dialog. Thanx a lot.

        K 1 Reply Last reply
        0
        • S swaapu

          Hi! I hav an MFC SDI Application with two dialogs. One is for selecting source file and the other is for selecting destination file. BOth, dialogs have one edit box for browsing or editing the path of file. Actually, I don`t want to get the path of current exe. Instead, I want to get the file path from edit box of another file. I want to get the path , which was entered in the edit box for file name on the SelectSource dialog. Thanx a lot.

          K Offline
          K Offline
          khan
          wrote on last edited by
          #4

          How are you creating both the dialogs? If they are in the parent: CDialog1* m_pDialog1; CDialog2* m_pDialog2; Then you can include a pointer to the parent in dialog1: CParent* m_pParent; //in dialog1.h And have it initialized by the parent after the dialog creation: m_pDialog1 = new CDialog1.... ..... m_pDialog1->m_pParent = this; Then inside CDialog1: m_pParent->m_pDialog2->m_strFileName; //whatever the variable names are. So you can access the dialog2 from dialog1. I hope it is clear. this is this.

          S 1 Reply Last reply
          0
          • K khan

            How are you creating both the dialogs? If they are in the parent: CDialog1* m_pDialog1; CDialog2* m_pDialog2; Then you can include a pointer to the parent in dialog1: CParent* m_pParent; //in dialog1.h And have it initialized by the parent after the dialog creation: m_pDialog1 = new CDialog1.... ..... m_pDialog1->m_pParent = this; Then inside CDialog1: m_pParent->m_pDialog2->m_strFileName; //whatever the variable names are. So you can access the dialog2 from dialog1. I hope it is clear. this is this.

            S Offline
            S Offline
            swaapu
            wrote on last edited by
            #5

            HI!! Could u please suggest me some good books on MFC. I am learning MFC. I had never worked on it earlier. But, now I am working on a project. Currently, I am trying to develop an application for converting "ini" files to "xml" files through MFC. Thanx a lot.

            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