比如我的一个SDI程序编译后生成的.exe文件的路径为:
D:\MyCpp\MySDI\Debug\Mysdi.exe怎样获得:D:\MyCpp\MySDI\Debug\这个路径??
D:\MyCpp\MySDI\Debug\Mysdi.exe怎样获得:D:\MyCpp\MySDI\Debug\这个路径??
解决方案 »
- js调用MFC,JS那里总是提示错误
- Radio Button 与ICO, 很简单的
- 求Visual C++实用教程(第2版)-郑阿奇-电子工业出版社的电子书
- InstallShield预处理的问题
- 在CView类中动态创建了一些Edit控件后,但不能响应TAB键! 急~~~
- 各位看看下面的问题是什么原因导致的,Unhandled exception
- 我需要一个读写修改注册表的完整的类-----------wait online.....
- 如何编程控制IIS的设置,请指教!
- 最后淡待遇时要注意些什么?在线等待你的高见
- 郁闷中......
- 如果要求输入int类型变量,但是输入了字符,怎么识别
- 如何彻底隐藏文件夹?
The GetCurrentDirectory function retrieves the current directory for the current process. DWORD GetCurrentDirectory(
DWORD nBufferLength, // size of directory buffer
LPTSTR lpBuffer // directory buffer
);
DWORD nBufferLength, // size, in characters, of directory buffer
LPTSTR lpBuffer // pointer to buffer for current directory
);
然后自己将后面的exe去掉就是你要的目录路径了
DWORD GetModuleFileName(
HMODULE hModule, // handle to module
LPTSTR lpFilename, // path buffer
DWORD nSize // size of buffer
);
hModule
[in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module.
lpFilename
[out] Pointer to a buffer that receives the fully-qualified path for the module. If the length of the string exceeds the size specified by the nSize parameter, the string is truncated.
Windows NT/2000/XP: The path can have the prefix "\\?\", depending on how the module was loaded. For more information, see File Name Conventions. nSize
[in] Specifies the length of the lpFilename buffer, in TCHARs.
char *p = _tcsrchr(m_szPath, '\\') + 1;
*p = '\0';