-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHWPath.cpp
39 lines (36 loc) · 977 Bytes
/
HWPath.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "stdafx.h"
#include "HWPath.h"
#include "HWStrSafe.h"
DLLXEXPORT BOOL WINAPI HWPathAppend( LPWSTR pszPath, LPCWSTR pszFile)
{
TCHAR szPath[MAX_PATH] = {0};
if (!pszPath)
{
return FALSE;
}
StringCchCopy(szPath, _countof(szPath), pszPath);
if (HWPathAppend_s(szPath, _countof(szPath), pszFile))
{
wcscpy(pszPath, szPath);
return TRUE;
}
return FALSE;
}
DLLXEXPORT BOOL WINAPI HWPathAppend_s( LPWSTR pszPath,DWORD dwLen, LPCWSTR pszFile)
{
if (!pszPath || !pszFile)
{
return FALSE;
}
WCHAR szPath[MAX_PATH] = {0};
WCHAR szFile[MAX_PATH] = {0};
StringCchCopy(szPath, _countof(szPath), pszPath);
StringTrimRight(szPath, L" \t\\/");
StringCchCopy(szFile, _countof(szFile), pszFile);
StringTrimLeft(szFile, L" \t\\/");
//HWTRACE(TEXT("%s\n"), szFile);
StringCchCat(szPath, _countof(szPath), L"\\");
StringCchCat(szPath, _countof(szPath), szFile);
StringCchCopy(pszPath, dwLen, szPath);
return TRUE;
}