Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <direct.h>
  3.  
  4. char current_work_dir[FILENAME_MAX];
  5. _getcwd(current_work_dir, sizeof(current_work_dir));
  6.  
  7. #include <windows.h>
  8. #include <tchar.h>
  9.  
  10. LPTSTR ExtractFilePath(LPCTSTR FileName, LPTSTR buf)
  11. {
  12. int i, len = lstrlen(FileName);
  13. for(i=len-1; i>=0; i--)
  14. {
  15. if(FileName[i] == _T('\'))
  16. break;
  17. }
  18. lstrcpyn(buf, FileName, i+2);
  19. return buf;
  20. }
  21.  
  22. // szFileName - содержит путь к exe-файлу
  23. // szPath - содержит путь к папке, в которой находится exe-файл
  24. TCHAR szFileName[MAX_PATH], szPath[MAX_PATH];
  25. GetModuleFileName(0, szFileName, MAX_PATH);
  26. ExtractFilePath(szFileName, szPath);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement