diff --git a/10-PixelShaderTips/10-PixelShaderTips.cpp b/10-PixelShaderTips/10-PixelShaderTips.cpp index 91e45f278f1983617bc0ac18e30c2675ead9f537..c48dc291f0ed7874639f3a56918613e1ae213143 100644 --- a/10-PixelShaderTips/10-PixelShaderTips.cpp +++ b/10-PixelShaderTips/10-PixelShaderTips.cpp @@ -269,15 +269,26 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l { // 得到当前的工作目录,方便我们使用相对路径来访问各种资源文件 { - UINT nBytes = GetCurrentDirectory(MAX_PATH, g_pszAppPath); - if (MAX_PATH == nBytes) + if (0 == ::GetModuleFileName(nullptr, g_pszAppPath, MAX_PATH)) { GRS_THROW_IF_FAILED(HRESULT_FROM_WIN32(GetLastError())); } WCHAR* lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); if (lastSlash) - { + {//删除Exe文件名 + *(lastSlash) = _T('\0'); + } + + lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); + if (lastSlash) + {//删除x64路径 + *(lastSlash) = _T('\0'); + } + + lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); + if (lastSlash) + {//删除Debug 或 Release路径 *(lastSlash + 1) = _T('\0'); } } diff --git a/11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp b/11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp index f3f910abd0e1e7c628d0570a3c2e21090ea7e5c1..804b0fc698bd08aa3becc09985dfc7e2161103b0 100644 --- a/11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp +++ b/11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp @@ -358,15 +358,26 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l // 得到当前的工作目录,方便我们使用相对路径来访问各种资源文件 { - UINT nBytes = GetCurrentDirectory(MAX_PATH, g_pszAppPath); - if (MAX_PATH == nBytes) + if (0 == ::GetModuleFileName(nullptr, g_pszAppPath, MAX_PATH)) { GRS_THROW_IF_FAILED(HRESULT_FROM_WIN32(GetLastError())); } WCHAR* lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); if (lastSlash) - { + {//删除Exe文件名 + *(lastSlash) = _T('\0'); + } + + lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); + if (lastSlash) + {//删除x64路径 + *(lastSlash) = _T('\0'); + } + + lastSlash = _tcsrchr(g_pszAppPath, _T('\\')); + if (lastSlash) + {//删除Debug 或 Release路径 *(lastSlash + 1) = _T('\0'); } }