Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

  1. #include <setuputil.h>
  2. #include <debugex.h>
  3. //
  4. // Function: CompleteToFullPathInSystemDirectory
  5. // Description: Get file name and a buffer. Return in the given buffer the full path to the file name in the
  6. // system directory
  7. // Returns: TRUE for success, FALSE otherwise
  8. //
  9. // Remarks: It is possible that the file name is in the given buffer.
  10. //
  11. // Args:
  12. // LPTSTR lptstrFullPath (OUT) : Buffer that will have the full path
  13. // LPTCSTR lptstrFileName (IN) : File name
  14. //
  15. // Author: AsafS
  16. BOOL
  17. CompleteToFullPathInSystemDirectory(
  18. LPTSTR lptstrFullPath,
  19. LPCTSTR lptstrFileName
  20. )
  21. {
  22. DBG_ENTER(TEXT("CompleteToFullPathInSystemDirectory"));
  23. TCHAR szFileName[MAX_PATH+1] = {0};
  24. DWORD dwSize = 0;
  25. _tcsncpy(szFileName, lptstrFileName, MAX_PATH);
  26. if (!GetSystemDirectory(lptstrFullPath, MAX_PATH))
  27. {
  28. CALL_FAIL(
  29. GENERAL_ERR,
  30. TEXT("GetSystemDirectory"),
  31. GetLastError()
  32. );
  33. return FALSE;
  34. }
  35. dwSize = _tcslen(lptstrFullPath);
  36. _tcsncat(
  37. lptstrFullPath,
  38. TEXT("\\"),
  39. (MAX_PATH - dwSize)
  40. );
  41. dwSize++;
  42. _tcsncat(
  43. lptstrFullPath,
  44. szFileName,
  45. (MAX_PATH - dwSize)
  46. );
  47. return TRUE;
  48. }