Reading responses to a similar post I learned GetModuleFileNameEx () is a
good start. But MSDN doesn't have any examples and I am baffled. Being a
beginner I can't quite understand what HMODULE and the such are; again
reading the definitions in MSDN can't convince me I understood.
Please give me an example, or just a one line example of
GetModuleFileNameEx().
If possible also tell me how to extract just the Directory Name (full path
to directory) by crossing out the filename.
For your reference, I am copying the syntax of GetModuleNameEx() from MSDN,
which I just can't understand...
====
GetModuleFileNameEx
-------------------
The GetModuleFileNameEx function retrieves the fully qualified path for the
specified module.
DWORD GetModuleFileNameEx(
HANDLE hProcess, // handle to the process
HMODULE hModule, // handle to the module
LPTSTR lpFilename, // buffer that receives the path
DWORD nSize // size of the buffer
);
Parameters
==========
hProcess:
---------
Handle to the process that contains the module.
hModule:
--------
Handle to the module.
lpFilename:
-----------
Pointer to the buffer that receives the fully qualified path to the module.
nSize:
------
Specifies the size, in bytes, of the lpFilename buffer.
Return Value
If the function succeeds, the return value specifies the length of the
string copied to the buffer.
======
Thank you...
-Michelle Stone
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
char szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, sizeof(szPath));
// returns full path and exe name.
// now get just the path:
strMY_APP_FOLDER = _T(szPath);
CString strMY_APP_FOLDER =
strMY_APP_FOLDER.Left(strMY_APP_FOLDER.ReverseFind('\\') + 1);
// include the backslash in the path
-- Alan
--------------------
Michelle Stone wrote:
--
---------------------------------------------------
Alan Mukamal
amuk...@ix.netcom.com
---------------------------------------------------
Hope this helps !
--
Felix Brack
LTEC AG
Dorfgasse 10
CH-4435 Niederdorf
SWITZERLAND
Internet: http://www.ltec.ch
Tel. +41 61 963 14 14
Fax. +41 61 963 14 13
E-Mail: f...@ltec.ch
Michelle Stone <mich_...@yahoo.com> wrote in message
news:LPBBKCMNDFHABFONJFL...@yahoo.com...
CFile myFile;
...
myFile.Open("CodList.Dat",CFile::modeCreate|CFile::shareDenyNone|CFile::mode
Write);
For me, it work writing the file in the exact directory where I have my
executable...
Fernando de Almeida Peres
Michelle Stone wrote in message ...