使用VC 獲取檔案路徑,已獲取當前路徑為基礎

2021-06-22 03:11:35 字數 690 閱讀 7308

[cpp]view plain

copy

今天搞清楚了如果使用c++獲取當前路徑,並且已獲取當前路徑為基礎,測試**如下,如果有注釋錯誤還請看到的高手指正,呵呵~~  

[cpp]view plain

copy

#include 

#include 

#include 

using

namespace

std;  

intmain()  

getcurrentdirectory(1000,buf);  

//這裡用兩個反斜槓是必須得,因為這不通過作業系統來進行目錄切換,

//只是簡單的字串拼接

strcat(buf,"\\srvice_windows\\srvice_windows"

);  

cout << buf << endl;  

a.assign(buf);  

test = setcurrentdirectory(a.c_str());  

if(test == 0 )  

getcurrentdirectory(1000,buf);  

cout<

return

0;  

}  

獲取當前檔案路徑

getcurrentdirectory只是返回當前程序的當前目錄,而並不是程序的映象檔案 exe 所在的目錄 getcurrentdirectory 適用於xp等系統,在wince上不能使用 getmodulefilename 適用於wince2.0以後 使用方法 下面的一段 主要是獲得當前程式的執...

獲取當前檔案路徑。

之前搞模組載入,苦於無法獲取當前檔案路徑,檔名 後來沒通過獲取當前檔案路徑,檔名,給搞定了。結果今天把這個問題也解決了,做個記錄 file zhus err.js varcursrc newfunction catch e console.log cursrc zhus err 以上編碼,只適用於f...

VC中獲取當前exe檔案執行路徑

一 tchar szfilepath max path 1 getmodulefilename null,szfilepath,max path tcsrchr szfilepath,t 1 0 刪除檔名,只獲得路徑 cstring str url szfilepath afxmessagebox ...