hInstance 可为NULL
或者GetModuleHandle(NULL);等方式获取
TCHAR* GetCurrPath(HINSTANCE hInstance, TCHAR* pPathBuf, int iBufLen)
{
if (pPathBuf == NULL)
{
return NULL;
}
memset(pPathBuf, 0x0, sizeof(TCHAR) * iBufLen);
int iLen = GetModuleFileName(hInstance, pPathBuf, iBufLen - 1);
if (iLen >= 0)
{
TCHAR* pLastPos = wcsrchr(pPathBuf, L'\\');
if (pLastPos != NULL)
{
*(pLastPos + 1) = L'\0';
}
}
return pPathBuf;
}