Sorry,my computer doesn't support Chinese IME.But you can answer it in Chinese.
解决方案 »
- 图形旋转问题
- VC如何打开一个硬盘上的文件
- 我发现一个BUG,不知道是不是?关于透明窗口。
- 英文好的给讲讲
- 弱弱的一个问题
- <北京银河通在线新技术有限公司> 这家公司怎么样?
- 请思归等高手看看hook弹出的MessageBox窗体问题!
- Win32 SDK编程模态对话框如何才能响应WM_KEYDOWN的消息?第一次问三百分的问题,实在是整了一天也没有搞出来
- 小妹请教:Cpropertysheet和Cpropertypage制作向导时如何用自己的按钮代替自动生成的按钮?
- opengl在多线程中的使用问题
- 如何设置CFileDialog的颜色???
- 十六大胜利闭幕了,,可是我的程序还没有做出来,vc+dao+access怎么样查询记录:)
HMODULE hModule, // handle to module
LPTSTR lpFilename, // file name of module
DWORD nSize // size of buffer
);
Parameters
hModule
[in] Handle to the module whose file name is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file containing the current process.
lpFilename
[out] Pointer to a buffer that receives the path and file name of the specified module.
nSize
[in] Specifies the length, in TCHARs, of the lpFilename buffer. If the length of the path and file name exceeds this limit, the string is truncated.
The GetCurrentDirectory function retrieves the current directory for the current process. DWORD GetCurrentDirectory(
DWORD nBufferLength, // size, in characters, of directory buffer
LPTSTR lpBuffer // pointer to buffer for current directory
);
对于Win32应用程序来讲,获得可执行文件的路径其实十分简单,只要调用__argv[0]即可。下面的代表你可以加在任何地方,都会看到你的应用程序名:AfxMessageBox(__argv[0]);
{
char *szCmd=NULL,*pc=NULL;
int nPathLen=0;
char *szPath=NULL;
CString m_ExeDir;
szCmd=GetCommandLine(); if (szCmd[0]!='\"') return "";
for (pc=szCmd+1; *pc; pc++)
if (*pc=='\"') break;
for ( ; pc>=szCmd+1; pc--)
{
if (*pc=='\\') break;
if (*pc=='/') break;
}
nPathLen=pc-(szCmd+1);
if (nPathLen<=0) return "";
szPath=(char *)malloc(nPathLen+1); if (szPath==NULL) return "";
memcpy(szPath,szCmd+1,nPathLen); szPath[nPathLen]=0;
m_ExeDir=szPath;
free(szPath); return m_ExeDir;
}