File Handle(very urgent)
-
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
-
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
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 usingHMODULE hModule; hModule = LoadLibrary(...)
, its handle is returned. This is the same handle for use withGetModuleFileName(...).
this is this. -
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 usingHMODULE hModule; hModule = LoadLibrary(...)
, its handle is returned. This is the same handle for use withGetModuleFileName(...).
this is this.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.
-
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.
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. -
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.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.