c++ 获取文件路径
(2010-06-21 16:04:27)
标签:
c文件路径driveit |
分类: C/CPP |
一、获取应用程序路径:
CString
strPath;
TCHAR
szFull[_MAX_PATH];
TCHAR
szDrive[_MAX_DRIVE];
TCHAR
szDir[_MAX_DIR];
::GetModuleFileName(NULL, szFull,
sizeof(szFull)/sizeof(TCHAR));
_tsplitpath(szFull, szDrive, szDir, NULL, NULL);
_tcscpy(szFull, szDrive);
_tcscat(szFull, szDir);
strPath =
CString(szFull);
二、获取ocx自身路径:
CString ls_FileName;
LPTSTR lpBuffer;
UINT uSize;
HANDLE hHeap;
uSize=(GetCurrentDirectory(0,NULL))*sizeof(TCHAR);
hHeap=GetProcessHeap();
lpBuffer=(LPTSTR)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,uSize);
GetCurrentDirectory(uSize,lpBuffer);
ls_FileName=CString(lpBuffer);
二、获取ocx自身路径:
后一篇:VSS 错误